Master detail split styling in android

末鹿安然 提交于 2019-12-03 03:21:38

问题


This question probably has been asked many times over here, without yielding useful answers. I'd place it here with a possible answer. Feel free to improve.

Question: How to setup popup like style of detail view, in side by side master detail view as highlighted in image below:


回答1:


In this solution , I have used 9-patch background images, to define 2 kinds of backgrounds for list items. So, the selected(checked) list Item has a different background, as shown:

(list item)

(selected item)

(list item)

The list item layout's parent view, is a class extending LinearLayout (can be any ViewGroup) and implementing Checkable. Hence, when ListView is set to choice mode, it can automatically check/uncheck this view. This checked state is then used by selector background assigned to this view :

<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_checked="true" android:drawable="@drawable/checked"/>
  <item android:drawable="@drawable/unchecked"/>
</selector>

This makes the background of list item view change automatically, without having to do it manually in code every time a list item is selected.

Result:

Additional points:

  1. Scrollbar can be moved to left side.
  2. Use list dividers that match shadow color, or more padding can be placed between list items and detail view.


来源:https://stackoverflow.com/questions/14032448/master-detail-split-styling-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!