Android 安卓:为什么我的布局背景图像被放大和模糊?

Android 安卓:为什么我的布局背景图像被放大和模糊?,android,xml,Android,Xml,我正在制作一个简单的聊天应用程序,我制作了一个.9.pngpic作为语音泡泡。下面是消息项布局XML(用户发送的气泡)的一部分: @drawable/bg\u send是位于app\res\的102px*102px.9.png文件。我原以为在我的5英寸1920*1080手机上显示的应该是小屏幕,但它比它应该的大,这导致了模糊 如果我想让它成为我想要的,我应该怎么做?图像延伸到线性布局的大小(它是背景)。文本视图周围的边距使线性布局更大。移动android:layout\u margin=“

我正在制作一个简单的聊天应用程序,我制作了一个
.9.png
pic作为语音泡泡。下面是消息项布局XML(用户发送的气泡)的一部分:


@drawable/bg\u send
是位于
app\res\
的102px*102px
.9.png
文件。我原以为在我的5英寸1920*1080手机上显示的应该是小屏幕,但它比它应该的大,这导致了模糊


如果我想让它成为我想要的,我应该怎么做?

图像延伸到线性布局的大小(它是背景)。文本视图周围的边距使线性布局更大。移动
android:layout\u margin=“10dp“
属性设置为LinearLayout,以便在气泡周围留有边距。

图像拉伸到LinearLayout的大小(它是背景)。文本视图周围的边距使线性布局更大。将android:layout\u margin=“10dp”属性移动到LinearLayout,以便在气泡周围有一个边距。

试试这个

<LinearLayout
android:id="@+id/right_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
>

<TextView
    android:id="@+id/right_msg"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_margin="10dp"
    android:background="@drawable/bg_send"
    android:textColor="@color/abc_primary_text_material_dark"/>

祝你好运试试这个

<LinearLayout
android:id="@+id/right_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
>

<TextView
    android:id="@+id/right_msg"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_margin="10dp"
    android:background="@drawable/bg_send"
    android:textColor="@color/abc_primary_text_material_dark"/>


祝你好运

不要使用.9.png,而是使用可绘制图像。下面是满足您需求的xml代码

res/drawable/bg_textview.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
    <solid android:color="#607D8B"/>
    <corners android:radius="30dp"/>
</shape>

不要使用.9.png,而是使用可绘制图像。下面是满足您需求的xml代码

res/drawable/bg_textview.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
    <solid android:color="#607D8B"/>
    <corners android:radius="30dp"/>
</shape>


如果删除
文本视图
上的
版面空白
,是否有帮助?编辑:还有,答案可能有用。有多少个
drawable
文件夹?将此图像放入res文件夹中所有可用的drawable文件夹中,然后检查它。@IntelliJAmiya首先,只有一个文件夹。然后我创建了
hdpi
mdpi
xdpi
等等,然后把这个图像放在所有这些图像中,但仍然没有用。@bhaveshN我试着把它们放进
hdpi
mdpi
xdpi
xxxdpi
。它保持不变。如果删除
文本视图
上的
版面_边距
,是否有帮助?编辑:还有,答案可能有用。有多少个
drawable
文件夹?将此图像放入res文件夹中所有可用的drawable文件夹中,然后检查它。@IntelliJAmiya首先,只有一个文件夹。然后我创建了
hdpi
mdpi
xdpi
等等,然后把这个图像放在所有这些图像中,但仍然没有用。@bhaveshN我试着把它们放进
hdpi
mdpi
xdpi
xxxdpi
。它仍然是一样的。遗憾的是,我试过了,但仍然不起作用。即使里面没有文字,图像也没有拉伸(一个圆),图像也更大更模糊。遗憾的是,我试过了,但仍然不起作用。即使里面没有文字,图像也没有拉伸(一个圆),图像也更大更模糊。非常感谢~这种方法比我预期的更好地解决了我的问题@如果答案有助于解决您的问题,请接受。这将对其他人有所帮助。谢谢:)非常感谢~这种方法比我预想的更好地解决了我的问题@如果答案有助于解决您的问题,请接受。这将对其他人有所帮助。谢谢:)