首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >9补丁图像未拉伸

9补丁图像未拉伸
EN

Stack Overflow用户
提问于 2019-03-09 05:17:49
回答 1查看 262关注 0票数 0

我试图使用9补丁图像来显示这个气球,尽管背景图像似乎没有根据我定义的文本进行拉伸。

我已经设置了内容区域,如图1所示。当前输出如图2所示。

我随时欢迎你的帮助。谢谢。

代码语言:javascript
复制
<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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-03-09 05:59:34

我用9-patch复制粘贴了你的TextView (作为balloon.9.png添加到res > drawable中),它工作了。

这是我的布局:

代码语言:javascript
复制
<?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>

下面是(来自模拟器的)输出:

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55071130

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档