Создать xml файл Shadow.xml
в папке Android drawable
.
<?xml version="1.0" encoding="utf-8" ?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item >
<shape
android:shape="rectangle">
<solid android:color="@android:color/darker_gray" />
<corners android:radius="5dp"/>
</shape>
</item>
<item android:right="6dp" android:left="6dp" android:bottom="9dp">
<shape
android:shape="rectangle">
<solid android:color="@android:color/white"/>
<corners android:radius="5dp"/>
</shape>
</item>
</layer-list>
Uasge: установить тень на фоне макета. Используйте свойство divider, чтобы установить расстояние между каждым элементом в просмотре списка.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:gravity="center"
android:background="@drawable/shadow"
android:orientation="vertical">
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:dividerHeight="20px"
android:divider="@android:color/darker_gray"
android:layerType="software"
/>
</LinearLayout>
MainActivity:
ListView listView = FindViewById<ListView>(Resource.Id.listview);
string[] s = new string[] { "a", "b", "c","d","e","f","g","h","i","j","k" };
ArrayAdapter<string> arrayAdapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, s);
listView.Adapter = arrayAdapter;