Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/209.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我如何开发这种按钮_Java_Android - Fatal编程技术网

Java 我如何开发这种按钮

Java 我如何开发这种按钮,java,android,Java,Android,此按钮外部为白色,内部为灰色背景。 内部背景包含图像(勾号)和文本(应用) 我能做出这样的形状(如下) 我正在drawable(button.xml)中使用一个形状: 并使用ImageView来使用该形状 <ImageView android:id="@+id/button_apply" android:layout_width="wrap_content" android:layout_height="wrap_content" android:s

此按钮外部为白色,内部为灰色背景。
内部背景包含图像(勾号)和文本(应用)

我能做出这样的形状(如下)

我正在drawable(button.xml)中使用一个形状:


并使用ImageView来使用该形状

<ImageView
    android:id="@+id/button_apply"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/button"/>

但我无法将文本做成形状。

我是否遗漏了什么或者有什么可能吗?

我会这样做:

1-将您的图层列表分为两个不同的绘图表

circle.xml

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval"
    >
        <size android:height="85dp" android:width="90dp" />
        <solid android:color="@color/grey" />
        <stroke android:color="@color/white" android:width="4dp" />
</shape>
根据需要调整重力和衬垫。
还可以根据需要设置一些其他属性

请注意,您可以(也应该)使用字符串资源,而不是硬编码文本


简要说明:

  • 我使用椭圆形作为文本视图的括号
  • 我正在使用复选标记位图作为复合绘图
  • 我正在使用TextView的文本来写一些东西
  • 我将文本视图设置为可点击,这样您就可以像使用按钮一样使用它

理解该问题时是否有问题?还是不相关?博博马罗加请再次考虑这个问题。我没有足够的声誉。因此无法发布图像。而且不知道它需要登录。
我无法以图形形式制作文本
文本本身不是绘图的一部分。您可以使用drawable作为TextView的背景。并使用文本视图的文本。@Bobmaloga你能投票支持这个问题吗。否则,我需要等待2天来问这个问题:(我添加了一个完整的答案,应该可以帮助你用一个简单的技巧解决你的问题。
<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval"
    >
        <size android:height="85dp" android:width="90dp" />
        <solid android:color="@color/grey" />
        <stroke android:color="@color/white" android:width="4dp" />
</shape>
<TextView
    android:id="@+id/button_apply"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:backgound="@drawable/button"
    android:drawableTop="drawable/checkmark_filled"
    android:text="APPLY"
    android:clickable="true"
/>