简体   繁体   中英

How to create rounded rectangle ListView (ListActivity) in android?

Currently iam working in android application, Using ListActivity to create ListView, i give three items in ListView and setBackground image for Rounded rect in ListView, then run the app each corner has rounded rect showing fine, but rounded rect show in full screen, i want rounded rect until item 3. How to fix this? please help me

Thanks in Advance

I tried this:

ListView class:

public class Settings extends ListActivity
{
     private static String[] mListContent={"Item 1", "Item 2", "Item 3"};
     public void onCreate(Bundle savedInstanceState)
     {
            super.onCreate(savedInstanceState);

            // Set listview rounded rect
            getListView().setCacheColorHint(0);
            getListView().setBackgroundResource(R.drawable.custom_shape);

            setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mListContent));
            }
}

Custom_shape.xml file

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <stroke android:width="4dp" android:color="#FFFFFF" />
    <padding android:left="14dp" android:top="14dp"
            android:right="14dp" android:bottom="14dp" />
    <corners android:radius="8dp" />
</shape>

Below i have attached image for your reference:

i want to show the border line (ListView) end of the item 3. // its similarly grouped tableview in iPhone

在此处输入图片说明

I want to show like this:

在此处输入图片说明

ListView高度以XML作为包装内容而不是od填充父级传递...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM