我正在尝试创建下面这样的可绘制对象::
我是用以下代码创建的:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@color/white"
android:padding="10dp"
android:orientation="vertical">
<View
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@drawable/bg_round_button_green"/>
<View
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:background="@drawable/bg_round_button_green"/>
<TextView
android:layout_width="match_parent"
android:layout_height="36dp"
android:text="Text"
android:textColor="@color/white"
android:textSize="22sp"
android:gravity="center"
android:layout_centerVertical="true"
android:background="@color/siam_green3"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"/>
</RelativeLayout>
bg_round_button_green.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="ring">
<solid android:color="#FF0DAB61"/>
</shape>
我也尝试了这个: bg_round_button_green.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FF0DAB61"/>
<corners android:radius="100dp"/>
</shape>
但它会显示:
是否可能只使用单个形状可绘制对象来完成此操作(而无需创建三个视图)?
android:background="@drawable/bg_round_button_green"
пјҢиҖҢдёҚжҳҜandroid:background="@color/siam_green3"
гҖӮ - Phantômaxx