简体   繁体   中英

How to make button like this in Android?

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

在此处输入图片说明

i have already implemented button like this

在此处输入图片说明

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>

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>

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.

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

在此处输入图片说明

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM