【发布时间】:2016-10-13 18:06:54
【问题描述】:
此按钮的外层为白色,内层为灰色。
内部背景包含一个图像(勾号)和一个文本(应用)。
我可以做出这样的形状(下图)。
我在 drawable (button.xml) 中使用了一个形状:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="oval">
<size android:height="85dp"
android:width="90dp"/>
<solid android:color="@color/grey"/>
<stroke android:color="@color/white" android:width="4dp"></stroke>
</shape>
</item>
<item
android:drawable="@drawable/checkmark_filled"
android:bottom="20dp"
android:left="20dp"
android:right="20dp"
android:top="20dp"/>
</layer-list>
并使用 ImageView 来使用形状
<ImageView
android:id="@+id/button_apply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/button"/>
但我无法制作形状文本。
我错过了什么还是有什么办法?
【问题讨论】:
-
题主理解有问题吗?还是无关紧要?
-
@BobMalooga 请再次考虑这个问题。我没有足够的声望。所以无法发布图片。并且不知道它需要登录。
-
i am not able to make a text in shape文本不是可绘制对象本身的一部分。您可以做的是使用可绘制对象作为 TextView 的背景。并使用 TextView 的文本。 -
@BobMalooga 你能投票赞成这个问题吗?否则我需要等待 2 天才能提出问题 :(
-
我添加了一个完整的答案,应该可以帮助您通过一个简单的技巧解决您的问题。