我试图用9补丁图像显示这个气球,虽然背景图像似乎没有根据我定义的文本拉伸。
我已将内容区域设置为图像1所示。当前输出显示在图像2中。
我欢迎任何帮助。谢谢。
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/balloonView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title this is dummy text, this is dummy text, this is dummy text"
android:textSize="13dp"
android:textColor="@android:color/white"
android:background="@drawable/balloon" />
我做了你的TextView
复制粘贴9补丁(添加到res > drawable
作为balloon.9.png
),它的工作原理。
这是我的布局:
<?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:orientation="vertical"
android:background="@color/colorPrimary"
android:padding="50dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/balloon"
android:text="Title this is dummy text, this is dummy text, this is dummy text"
android:textColor="@android:color/white"
android:textSize="13dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/balloon"
android:text="Title this is dummy text, this is dummy text, Title this is dummy text, this is dummy text, Title this is dummy text, this is dummy text, Title this is dummy text, this is dummy text, Title this is dummy text, this is dummy text, Title this is dummy text, this is dummy text, Title this is dummy text, this is dummy text, Title this is dummy text, this is dummy text, this is dummy text"
android:textColor="@android:color/white"
android:textSize="13dp" />
<TextView
android:layout_width="200dp"
android:layout_height="200dp"
android:background="@drawable/balloon"
android:gravity="center"
android:padding="40dp"
android:text="Title this is dummy text, this is dummy text, this is dummy text"
android:textColor="@android:color/white"
android:textSize="13dp" />
</LinearLayout>