繁体   English   中英

Android在可绘制按钮中添加文本

[英]Android add text in a drawable button

如何使用命令“ android:text =“ test”在主xml文件中以经典方式添加文本而不在经典图形中添加文本,但是我想在可绘制xml中添加图像按钮的文本(代码2) )。

代码1-main.xml:

     <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>

为什么不使用按钮并将可绘制对象作为背景? 这是看这里的好链接

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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