android - 9-patch 图像在 TextView 周围绘制 1 个像素的边框

标签 android nine-patch

enter image description here <-- 这是一张 3x3 的图片。抱歉。

我使用以下 3x3 图片。

因此,当我使用 draw9patch.bat 打开并分别在顶部和左侧添加 2 个像素时,我得到以下图像。

enter image description here

我希望如果我将此图像应用到 TextView,我的整个 TextView 将在其周围有 1 像素宽的边框。

但是,我只设法得到“半边”。右侧和底部的边框缺失。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center_horizontal|center_vertical"
    android:orientation="vertical"
    android:background="#ffffff" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TextView"
        android:background="@drawable/border" />

</LinearLayout>

enter image description here

我的 9 补丁图像有什么问题吗?

enter image description here <-- 用于测试目的的 9 个补丁图像。

最佳答案

尝试在其周围添加 1px 的空白区域。见附图。

padded bg

关于android - 9-patch 图像在 TextView 周围绘制 1 个像素的边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11645284/

相关文章:

android - drawable-nodpi 拉伸(stretch) 9 补丁

java - 一次创建包含子集合的文档

java - 如何在 Android 布局上正确分配 4 个按钮

android - 我如何着手设置涉及标签的用户界面?

Android Intent to Google Maps Navigation using Google Place id (not by Coordinates or Address)

java - 加载 9-patch 图像作为 Libgdx Scene2d 按钮背景看起来很糟糕

android - ContentResolver.openAssetFileDescriptor() 在 Android 12 中需要很长时间

Android 9 补丁工具 : What is the new layout bounds feature?

android - 具有两个可拉伸(stretch)区域的 9-Patch

android - 调整 TextView 大小以适合文本(带有 9-patch 背景图像)?