gpt4 book ai didi

android - Optical Bounds 9-patch 禁用内容填充

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

似乎在父布局上设置 layoutMode="opticalBounds" 会禁用 9-Patch 内容区域。下面的屏幕截图是一个简单的 TextView:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="20dp"
android:paddingTop="20dp">

<TextView
android:layout_width="200dp"
android:layout_height="200dp"
android:background="@drawable/shadow_with_stroke_gray"
android:text="lorem ipsum etc"
android:padding="0dp"
/>
</FrameLayout>

而左侧的 FrameLayout 将其 layoutMode 设置为默认值 (clipBounds),而右侧的设置为 opticalBounds

9 补丁 PNG 也附在这篇文章中。

这种情况下的正确行为是什么?

TextView paddings gone

正在使用的 9 补丁图像:

enter image description here

根据评论者的建议更新了 9-Patch 图片:

Updated 9-Patch image

更新了来自 SDK 的官方文件

使用来自 SDL (samples/android-20/legacy/ApiDemos/res/drawable-mdpi/btn_default_normal.9.png) 的 9 补丁图像,结果如下所示:

Using SDK file

SDK文件(我添加的光学边界的红色标记):

9-Patch from SDK

问题仍然存在,内容区域未被考虑在内,文本不应绘制在边框上。

最佳答案

删除了 android:padding="0dp" 并且 padding 是正确的。

关于android - Optical Bounds 9-patch 禁用内容填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25238989/

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