是否可以在TextView的背面添加带有可绘制元素的填充?还是我需要使用绘图9补丁?
<TextView
android:layout_width="wrap_content"
android:layout_gravity="bottom|left"
android:layout_marginLeft="5dp"
android:layout_height="85dp"
android:background="@drawable/text_background"
android:id="@+id/counter"
android:textColor="@color/white"
android:textSize="12sp"
android:textStyle="bold"
android:gravity="center"
android:paddingLeft="2dp"
android:paddingRight="2dp"
/>此填充设置不起作用。对于3-4位数字,背景显示是正确的,但当它应该调整( 5/6位数字)时,则保持不变。
更新-添加图像

发布于 2017-02-27 12:39:47
如果您要添加可绘图作为背景,那么drawablePadding就不能工作。
您只需给您适当的填充TextView,以便它可以处理您的大部分使用程序。
<TextView
android:id="@+id/txt_bankid_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/layout_user_detail"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/spacing_huge"
android:background="@drawable/textview_selector"
android:clickable="true"
android:textAllCaps="true"
android:padding="@dimen/spacing_small"
android:text="@string/login_bankid"
android:textColor="@color/app_background_color"
android:textSize="@dimen/font_normal" />不要给你的布局静态高度或宽度,因为你已经使用的高度。它将在不同的屏幕上造成问题,您将面临文本截止。
https://stackoverflow.com/questions/42485600
复制相似问题