9 патч изображение не растягивается - PullRequest
0 голосов
/ 09 марта 2019

Я пытаюсь показать этот воздушный шар, используя изображение с 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" />

image1

image2

image3

image4

1 Ответ

0 голосов
/ 09 марта 2019

Я сделал копию-вставку вашего 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>

А вот и вывод (из эмулятора): enter image description here

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...