Android在textview中调整九个补丁的大小

Android在textview中调整九个补丁的大小,android,screen,nine-patch,Android,Screen,Nine Patch,我有一个应该围绕文本的ninepatch图像(语音气泡)。当我设置文本视图的背景时,气泡会按原样显示,而不指定宽度或高度(它应该根据文本内容进行调整)。我的问题是,当用户从磁盘读取完全相同的映像时,映像的大小会调整 我在这里读了很多关于stackoverflow的不同答案,但没有找到任何真正适合我的解决方案 xml文件: <TextView android:id="@+id/someText" android:layout_marginBottom="20d

我有一个应该围绕文本的ninepatch图像(语音气泡)。当我设置文本视图的背景时,气泡会按原样显示,而不指定宽度或高度(它应该根据文本内容进行调整)。我的问题是,当用户从磁盘读取完全相同的映像时,映像的大小会调整

我在这里读了很多关于stackoverflow的不同答案,但没有找到任何真正适合我的解决方案

xml文件:

<TextView
        android:id="@+id/someText"
        android:layout_marginBottom="20dp"
        android:layout_marginTop="10dp"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:textColor="@android:color/background_dark"
        android:singleLine="true"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="This is a a line. "
        />
还尝试了另一种建议的解决方案:

TypedValue typedValue = new TypedValue();
//density none divides by the density, density default keeps the original size
typedValue.density = TypedValue.DENSITY_DEFAULT;
Drawable d = Drawable.createFromResourceStream(null, typedValue, fis, "test");'
但这两种解决方案都不适合我。有人知道我错过了什么吗


谢谢

如果您想将资源中没有的图像作为9-patch可绘制文件来处理,那么它就稍微复杂一些,您需要“编译”9-patch。所以答案可能会有帮助。好的,谢谢,我会调查的。
TypedValue typedValue = new TypedValue();
//density none divides by the density, density default keeps the original size
typedValue.density = TypedValue.DENSITY_DEFAULT;
Drawable d = Drawable.createFromResourceStream(null, typedValue, fis, "test");'