android - Trying to space items in a ListView while using adapter and drawable. Margin is not working -
i trying have listview items have rounded corners , items spaced out each other. done using custom arrayadapter.
mycustomadapter arradapter = new mycustomadapter(); setlistadapter(arradapter);
i using drawable image round corners
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <corners android:radius="10dp" /> <gradient android:angle="90" android:endcolor="#993333" android:startcolor="#ffffff" android:type="sweep" /> <solid android:color="#ffffff" /> <stroke android:width="1dp" android:color="#000000" /> </shape>
and setting in layout background top container - linearlayout
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="4dp" android:background="@drawable/square" android:orientation="horizontal" > <textview android:id="@+id/routetag" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="5dp" android:background="@drawable/circle" android:padding="10dp" android:text="text" android:textappearance="?android:attr/textappearancelarge" /> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <relativelayout android:layout_width="wrap_content" android:layout_height="wrap_content" > <textview android:id="@+id/stop" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="5dp" android:text="some text" android:textappearance="?android:attr/textappearancemedium" android:textsize="14sp" /> <textview android:id="@+id/stopd" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentright="true" android:padding="5dp" android:text="(text)" android:textcolor="#777777" android:textsize="10sp" /> </relativelayout> <relativelayout android:layout_width="wrap_content" android:layout_height="wrap_content" > <textview android:id="@+id/nexttt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingbottom="5dp" android:paddingleft="5dp" android:paddingright="9dp" android:paddingtop="5dp" android:text="text" android:textappearance="?android:attr/textappearancemedium" android:textsize="14sp" /> <textview android:id="@+id/morett" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_torightof="@id/nexttraintime" android:paddingbottom="5dp" android:text="text" android:textappearance="?android:attr/textappearancemedium" android:textsize="12sp" /> </relativelayout> </linearlayout> </linearlayout>
for reason in graphical display able see single element want - margins around (i want move away edges of screen left , right). when run , let adapter job getting list of items, touching sides of screen , no space between them apart forma single line used separate items on normal list.
anyone have clue how make behave?! have search far , wide.
thanks help
the space between item , widescreen can done with:
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:left="10dp" android:right="10dp" android:top="10dp" android:bottom="10dp"> <shape android:shape="rectangle">...</shape> </item>
in case used android:divider , android:dividerheight on listview block seperate each element of listview, , left-right space android:left
android:right
properties.
the post got info this
Comments
Post a Comment