2016-07-21 10 views
0

私は簡単なチャットアプリを作っています。私は.9.pngの絵を吹き出しにしました。ここではメッセージアイテムのレイアウトXML(ユーザーによって送られバブル)の一部です:Android:レイアウトの背景画像がズームしてぼやけているのはなぜですか?

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

    <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:textColor="@color/abc_primary_text_material_dark"/> 

</LinearLayout> 

@drawable/bg_sendapp\res\で102px * 102px .9.pngファイルです。私はそれが私の5" 1920×1080電話機に表示小さくしなければならないと思った。しかし、それがあるべきよりも大きいですし、それがぼやけ原因。

This pic is 1:1

私はそれを作りたい場合は、私が望むように私は何をすべき?

+1

あなたは 'TextView'に' layout_margin'を削除した場合、それは助けていますか? **編集:**また、[this](http://stackoverflow.com/questions/26130479/9patch-image-looks-blurry)の回答が役に立つかもしれません。 – PPartisan

+0

いくつの 'drawable'フォルダ? –

+0

この画像をresフォルダにあるすべてのドロウアブルフォルダに入れて確認してください。 –

答えて

3

代わりに、代わりに描画可能な画像を使用し.9.png使用します。あなたの要件を満たすxmlコードはここにあります。

のres /描画可能/ 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> 
+0

ありがとうございました〜このアプローチは私の問題を私が期待したよりもさらに良く解決しました! –

+0

@AlexFanあなたの問題を解決するのに役立つ場合は、回答を受け入れてください。それは他人に役立つでしょう。ありがとう:) –

0

画像はあなたのLinearLayoutのサイズに広がって(そのため、それがバックグラウンドである)。TextViewの周りのマージンはのLinearLayoutが大きくなります。バブルの周りに余裕を持ってのLinearLayoutにandroid:layout_margin="10dp"属性を移動します。

+0

悲しいことに私はそれを試みましたが、それはまだ動作しません。そして、内部にテキストがなくても画像が伸びていなくても(ラウンド)、それは大きくてぼやけています。 –

0

試す

<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"/> 

幸運

関連する問題