Android在可绘制按钮中添加文本
如何在可绘制图像按钮中添加文本,而不使用命令“android:text=“test”以经典方式在主xml文件中添加文本,但我想在可绘制xml中添加图像按钮的文本(代码2) 代码1-main.xml:Android在可绘制按钮中添加文本,android,xml,imagebutton,Android,Xml,Imagebutton,如何在可绘制图像按钮中添加文本,而不使用命令“android:text=“test”以经典方式在主xml文件中添加文本,但我想在可绘制xml中添加图像按钮的文本(代码2) 代码1-main.xml: <ImageButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_alignParentTop="t
<ImageButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:src="@drawable/start_off"
android:text="TEST"
android:background="@null"/>
代码2-可绘制xml按钮:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Define the background properties like color etc -->
<item android:id="@android:id/background">
<shape
android:shape="oval">
<gradient
android:angle="270"
android:startColor="#990000"
android:endColor="#ff0000"
/>
<corners
android:radius="4dp"
/>
<size
android:width="120dp"
android:height="120dp"
/>
</shape>
</item>
为什么不使用按钮并将可绘制的按钮作为背景?这里有一个很好的链接可以查看因为我使用此牵引代码通过USB更新按钮的状态(如果按钮打开或否),并且我只能使用图像按钮。