2016-11-28 1 views
-2

私はリストビューを持っており、行モデル/デザインは以下のイメージに示すようなものでなければなりません。イメージビューとテキストビューをカスタマイズする方法は?

私の質問は、3番目の行の画像に表示されるようにビューをデザインするにはどうすればいいですか?角を丸くした青い矩形のようなものをデザインして、画像上にその値を書きたい

これはtextviewかimageViewですか?どのように私はそのようなビューを設計することができますアドバイスをしてください

画像

enter image description here

+0

1つのTextViewを取るとのTextViewの描画可能な権利を設定し、設定maxems = 5またはあなたが好きとtextview.Youがありますよう丸い背景 –

+0

あなたはこれを実装することができます設定セレクタリソースファイルを作成してバックグラウンドを与える –

答えて

1

下のテキストビューの使用の背景として、あなたはを作成する必要がありますTextViewとそれに形状

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" >   
    <stroke 
     android:width="1dp" 
     android:color="@color/common_border_color" /> 

    <solid android:color="replace with blue color" /> 

    <padding 
     android:left="1dp" 
     android:right="1dp" 
     android:top="1dp" /> 

    <corners android:radius="5dp" /> 
    </shape> 

XMLでこれを作るには、描画可能なフォルダにrounded_corner.xmlと呼ばれます。

android:background="@drawable/rounded_corner" 
1

あなたがのTextViewを使用することができますし、XML

rounded_corner.xml

<?xml version="1.0" encoding="utf-8"?> 
<shape 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 

    <solid 
     android:color="#abcdef" > 
    </solid> 
    <corners 
     android:radius="20dp" > 
    </corners> 

</shape> 
0
In your drawable create one xml file and add this code in that 

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle" > 

<padding 
    android:top="3dp" 
    android:left="8dp" 
    android:right="8dp" 
    android:bottom="3dp"/> 

<solid android:color="#00796B" /> 

<corners 
    android:bottomLeftRadius="20dp" 
    android:bottomRightRadius="20dp" 
    android:topLeftRadius="20dp" 
    android:topRightRadius="20dp" /> 

In your view(Button/TextView) add background, some ex code 

<Button 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@drawable/delete" 
    android:text="Ur text"/> 
関連する問題