1. Are you ready for the Galaxy S20? Here is everything we know so far!

Including buttons making my canvas drawing like hexagon shape in Android ?

Discussion in 'Android Development' started by Zaheer Ahmed, Sep 4, 2018.

  1. Zaheer Ahmed

    Zaheer Ahmed Lurker
    Thread Starter

    I'm creating a canvas drawing app in Android that has lots of buttons in xml file. The problems is when I draw a circle with all those buttons included in the file it's never a smooth circle it's full of corners like hexagon shape but when I exclude buttons may be leaving in one or two, it draws a perfect smooth circle. I have tried to split the file into three so I've included them using but still same result.

    Code (Text):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    3.     xmlns:app="http://schemas.android.com/apk/res-auto"
    4.     xmlns:tools="http://schemas.android.com/tools"
    5.     android:layout_width="match_parent"
    6.     android:layout_height="match_parent"
    7.     tools:context=".MainActivity">
    8.  
    9. <!--First Draw -->
    10. <android.support.v4.widget.DrawerLayout
    11.     xmlns:android="http://schemas.android.com/apk/res/android"
    12.     xmlns:tools="http://schemas.android.com/tools"
    13.     android:id="@+id/drawer_layout"
    14.     android:layout_width="match_parent"
    15.     android:layout_height="match_parent"
    16.     tools:openDrawer="start">
    17.  
    18.     <LinearLayout
    19.         android:layout_width="fill_parent"
    20.         android:layout_height="fill_parent"
    21.         android:orientation="vertical" >
    22.  
    23.         <ImageButton
    24.             android:id="@+id/nav_one"
    25.             android:layout_width="30dp"
    26.             android:layout_height="60dp"
    27.             android:layout_marginTop="100dp"
    28.             android:layout_marginBottom="100dp"
    29.             android:background="@drawable/ic_tab_res_bkg"/>
    30.         <ImageButton
    31.             android:id="@+id/nav_two"
    32.             android:layout_width="30dp"
    33.             android:layout_height="60dp"
    34.             android:layout_marginTop="200dp"
    35.             android:background="@drawable/ic_tab_tools_bkg"/>
    36.     </LinearLayout>
    37.  
    38.     <FrameLayout
    39.         android:id="@+id/content_frame"
    40.         android:layout_width="match_parent"
    41.         android:layout_height="match_parent" />
    42.  
    43.    <!-- The navigation drawer -->
    44.  
    45.    <ListView android:id="@+id/resource_bank"
    46.         android:layout_width="350dp"
    47.         android:layout_height="match_parent"
    48.         android:layout_gravity="start"
    49.         android:choiceMode="singleChoice"
    50.         android:divider="@android:color/background_light"
    51.         android:dividerHeight="0dp"
    52.         android:background="#f4f1f1"
    53.         />
    54.     <ListView android:id="@+id/tools"
    55.         android:layout_width="350dp"
    56.         android:layout_height="match_parent"
    57.         android:layout_gravity="end"
    58.         android:choiceMode="singleChoice"
    59.         android:divider="@android:color/background_light"
    60.         android:dividerHeight="0dp"
    61.         android:background="#dedada"/>
    62.  
    63. </android.support.v4.widget.DrawerLayout>
    64.  
    65. <RelativeLayout
    66.     android:id="@+id/main"
    67.     android:layout_width="match_parent"
    68.     android:layout_height="match_parent"
    69.     android:layout_gravity="center" >
    70.  
    71.     <xxxxx.xxxxxx.xxxx.xxxxxx.DrawView
    72.         android:id="@+id/canvas_view"
    73.         android:layout_width="match_parent"
    74.         android:layout_height="match_parent"/>
    75.  
    76.     <FrameLayout
    77.         xmlns:android="http://schemas.android.com/apk/res/android"
    78.         android:layout_width="fill_parent"
    79.         android:layout_height="wrap_content"
    80.         android:layout_alignBottom="@+id/canvas_view">
    81.  
    82.         <!-- Pen icons -->
    83.  
    84.     <include  layout="@layout/activity_pen_color" android:id="@+id/pen_color" />
    85.     <include layout="@layout/activity_pen_style"  android:id="@+id/pen_style" />
    86.  
    87.         <!--  Navigation bar icons  -->
    88.  
    89.         <ImageView
    90.             android:id="@+id/icon_bar"
    91.             android:layout_width="match_parent"
    92.             android:layout_height="70dp"
    93.             android:layout_gravity="bottom"
    94.             android:background="@drawable/icon_bar_bkg"
    95.             />
    96.         <Button
    97.             android:id="@+id/ic_select"
    98.             android:layout_width="30dp"
    99.             android:layout_height="30dp"
    100.             android:layout_marginLeft="150dp"
    101.             android:layout_marginTop="60dp"
    102.             android:elevation="1dp"
    103.             android:background="@drawable/ic_select_bkg"/>
    104.         <TextView
    105.             android:id="@+id/text_select"
    106.             android:layout_width="wrap_content"
    107.             android:layout_height="wrap_content"
    108.             android:layout_marginLeft="150dp"
    109.             android:layout_marginTop="90dp"
    110.             android:text="Select"
    111.             android:textColor="@color/colorAccent"
    112.             />
    113.         <Button
    114.             android:id="@+id/ic_pens"
    115.             android:layout_width="30dp"
    116.             android:layout_height="30dp"
    117.             android:layout_marginLeft="200dp"
    118.             android:layout_marginTop="60dp"
    119.             android:elevation="1dp"
    120.             android:background="@drawable/ic_pen_bkg"/>
    121.         <TextView
    122.             android:id="@+id/text_pens"
    123.             android:layout_width="wrap_content"
    124.             android:layout_height="wrap_content"
    125.             android:layout_marginLeft="200dp"
    126.             android:layout_marginTop="90dp"
    127.             android:text="Pen"
    128.             android:textColor="@color/colorAccent"
    129.             />
    130.     </FrameLayout>
    131.   </RelativeLayout>
     


Loading...

Share This Page

Loading...