-3

Hello guys i know this is not a new question. I am getting help from HERE. In which i have success to make circle button with plane background but i want to make a button with background image like this:

Sample image

Here is related code for the layout:

<LinearLayout
    android:id="@+id/viewLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <View
        android:layout_width="0dp"
        android:layout_height="2dp"
        android:layout_weight="1"
        android:layout_gravity="center_vertical"
        android:background="@color/lighter_gray"/>
    <Button
        android:id="@+id/btnEdit"
        android:background="@drawable/button_circular"
        android:ellipsize="none"
        android:layout_width="0dp"
        android:layout_weight=".18"
        android:layout_height="wrap_content" />
    <View
        android:layout_width="0dp"
        android:layout_height="2dp"
        android:layout_weight="0.2"
        android:layout_gravity="center_vertical"
        android:background="@color/lighter_gray"/>
</LinearLayout>

@drawable/button_circular

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <solid android:color="@color/app_main_color"/>
    <stroke android:width="2dp" android:color="@color/app_main_color" />
</shape>

I also want to know is this a right way to get button like this? Thanks in advance.

Community
  • 1
  • 1
user3751280
  • 23
  • 1
  • 2
  • 8

1 Answers1

0

You should use Imageview Instead of Button

<ImageView
    android:id="@+id/btnEdit"
    android:background="@drawable/button_circular"
    android:ellipsize="none"
    android:layout_width="0dp"
    android:layout_weight=".18"
    android:layout_height="wrap_content" />
PageNotFound
  • 2,320
  • 2
  • 23
  • 34
Akash Jindal
  • 505
  • 3
  • 7