DevThapa
DevThapa

Reputation: 173

How to make button like this in Android?

I am trying to implement button in android with following layout.How to make it??

enter image description here

i have already implemented button like this

enter image description here

i used following code to make

<TextView
              android:id="@+id/action_text_share"
                            style="@style/mediumTextSize"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dip"
                            android:gravity="center"
                            android:singleLine="false"
                            android:text="Share by Text"
                            android:padding="10dp"
                            android:layout_weight="1"
                             android:background="@drawable/white_broder_round_with_transparent_bg"
                            android:textColor="@color/blackColor" />

and have drawable like this

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="@color/removeContactRedColor"/>
    <stroke android:width="2dip" android:color="@color/removeContactRedColor" />
    <corners 
       android:radius="5dip"
        />
</shape>

Upvotes: 0

Views: 192

Answers (3)

Rajan Kali
Rajan Kali

Reputation: 12953

Design a Background Image and Set it to Button with correct Padding and Margin

enter image description here

Set Text with The Background of Similar Above Image according to your Need

Upvotes: 0

Ankii Rawat
Ankii Rawat

Reputation: 2080

You can do like this in drawable, <item android:right="-2dp"> will remove stroke from the right end.

 <item android:right="-2dp">
    <shape>
        <corners android:radius="4dp"/>
        <solid android:color="@android:color/transparent" />
        <stroke
            android:width="1dp"
            android:color="@color/app_white" />
    </shape>
</item>

Upvotes: 1

Robin Dijkhof
Robin Dijkhof

Reputation: 19288

Some suggestions:

  1. Create a drawable image of the background and use this one as background.
  2. Assuming you created this with xml, create a solid blue shape and place it over the circle.

Upvotes: 0

Related Questions