gpt4 book ai didi

android - 9patch drawable 1px 黑线可见&内容定位

转载 作者:行者123 更新时间:2023-11-29 22:25:04 25 4
gpt4 key购买 nike

我得到了 9patch,感谢回答我上一个问题的好心人: enter image description here

我将它用于相对布局和 TextView 的背景,并得到了关注。那是 RelativeLayout 的:

  <RelativeLayout
android:id="@+id/relativeHeader"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android: background="@drawable/cap_stack">

enter image description here

对于 TextView:

<TextView
android:paddingTop="5dp"
android:gravity="center_vertical"
android:layout_width="fill_parent"
android:layout_height="22dp"
android:background="@drawable/cap_stack"
android:textStyle="bold"
android:textColor="#FFFFFF"/>

enter image description here

如您所见,在这两种情况下我都看到了 1px 宽的线条。在 TextView 的情况下,文本不会放置在垂直中心。我该如何修复它(是可绘制问题还是 xml)?将不胜感激任何帮助

最佳答案

您不应该一直使用实线边框。顶部和左侧边界定义了拉伸(stretch)区域(您只需要顶部的一个像素用于拉伸(stretch),并且您只想让渐变在垂直轴上拉伸(stretch))。底部和右侧边框定义了内容区域,因此您也想保留一些填充。永远不要填充四个角像素。

试试这个:

enter image description here

或者这个:

enter image description here

关于android - 9patch drawable 1px 黑线可见&内容定位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6178907/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com