user2121 user2121 - 9 days ago 6
Android Question

how to customize an image view and textview?

i have a listview and the row model/design should be something as shown in the image below.

My question is, how can I design a view to appear as shown in the image in the the third row?? I want to design something like the blue rectangular shape with round corners and then write the value on it as shown in the image

Is it a textview or imageView? Please advice how can i design such a view.

image:

enter image description here

Answer

You must create a TextView and give it a Shape:

<?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>

Make this in an xml called rounded_corner.xml in the drawable folder.

android:background="@drawable/rounded_corner"