Reputation: 783
I am trying to make simple Rounded Corner Shape ListView
Using below xmls;
row_layout.xml:-
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</RelativeLayout>
activity_main.xml:-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ListView
android:id="@+id/listView"
android:background="@drawable/layout_border"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
</RelativeLayout>
Upvotes: 1
Views: 249
Reputation: 76
set padding for textview in row_layout:
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold" />
</RelativeLayout>
set divide for listview in activity_main:
<ListView
android:id="@+id/listView"
android:background="@drawable/layout_border"
android:layout_height="wrap_content"
android:divider="#999999"
android:dividerHeight="3dp"
android:layout_width="wrap_content"/>
</RelativeLayout>
Upvotes: 0
Reputation: 9507
Put padding inside your Textview like...
<TextView
android:id="@+id/name"
android:padding="10dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
As you mentioned you need to change your border color in your layout_border.xml
.
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF"/>
<stroke android:width="3dip" android:color="#B1BCBE" /> Change color here
^^^^^^^^^
<corners android:radius="10dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>
Upvotes: 2
Reputation: 82938
Add padding to TextView of list row. And seems the required output doesn't have bold text so remove android:textStyle="bold"
from TextView
So you should update row_layout
<TextView
android:id="@+id/name" android:padding="10dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
OR
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dip"
android:paddingRight="5dip"
android:paddingTop="10dip"
android:paddingBottom="10dip"/>
Few other changes
into layout_border.xml
: -
<stroke android:width="1dip" android:color="#FF000000" /> // idip and color black
into activity_main.xml
:-
<ListView
android:id="@+id/listView"
android:background="@drawable/layout_border"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:dividerHeight="1dip"
android:divider="#FF000000"
/>
Upvotes: 1