In the first step we’re creating a new xml file named styles.xml in res/values/
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<style name="CustomListViewStyle" parent="@android:style/Widget.ListView">
<item name="android:background">#3F3F66</item>
<item name="android:fastScrollEnabled">true</item>
</style>
</resources>
What is important here? First of all we’ve created a custom style that extends its behavior from the default list view’s style.
In addition, we’re setting a new background color for the element and we’re enabling the fast scroll feature.
Last but not least we have to apply the style to an UI element e.g. modifying our ListView definition in the main.xml by setting a style-attribute
<ListView
android:id="@android:id/listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/CustomListViewStyle" >
</ListView>
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<style name="CustomListViewStyle" parent="@android:style/Widget.ListView">
<item name="android:background">#3F3F66</item>
<item name="android:fastScrollEnabled">true</item>
</style>
</resources>
What is important here? First of all we’ve created a custom style that extends its behavior from the default list view’s style.
In addition, we’re setting a new background color for the element and we’re enabling the fast scroll feature.
Last but not least we have to apply the style to an UI element e.g. modifying our ListView definition in the main.xml by setting a style-attribute
<ListView
android:id="@android:id/listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/CustomListViewStyle" >
</ListView>
No comments:
Post a Comment