Android - Preference - How to get os settings style in preference screen for my app

416 views Asked by At

I couldn't quite figure out how to achieve the shadow separator as with Lollipop os settings in my app's settings screen. Please see the screenshot below.

I know I can use a simple custom preference with a shadow drawable to get this look. But I wish to know if there is any built-in native way of doing this in android L and later.

Please help...

enter image description here

2

There are 2 answers

0
Androbean Studio On BEST ANSWER

I was looking for the same and, as it turns out that this is just a matter of setting "elevation" of the Viewgroups above and below.

I set elevation as 5dp for both the top and bottom ViewGroups and provided a margin of 10dp between them to get similar results.

Ofcourse its available only from L onwards. But I see that its L settings screenshot that you have provided.

0
chenupt On

@Androbean Studio is right. Checkout the Settings source. It create ui by DashboardSummary#rebuildUI.There is a view named categoryView with its xml layout. You will find the elevation attr in the LinearLayout.