search

Home  >  Q&A  >  body text

android - 像知乎设置页这样的列表样式是怎么实现的?

从这两大部分的阴影样式来看,感觉像是用了两个cardview,一个包含了上面「我的草稿,最近浏览。。等等条目」,另一个包含了「夜间模式」和「设置」,是这样吗?还是说整体就是一个RecyclerView?

另外,item之间的分割线是怎么做的?谢谢

高洛峰高洛峰2814 days ago780

reply all(3)I'll reply

  • 天蓬老师

    天蓬老师2017-04-17 18:03:10

    Because the number of these items is fixed and the number is small, you can write the entire list yourself. The copy style is actually the most efficient. The dividing line is actually a view with margin on the left. Set a background color. Height 1px

    reply
    0
  • PHPz

    PHPz2017-04-17 18:03:10

    All pages that look like preference settings can be implemented using the following Fragment:

    1. android.preference.PreferenceFragment, used in native environment

    2. android.support.v7.preference.PreferenceFragmentCompat, for compatible environments

    1, 2 have the same basic functions, except that 2 exists for compatibility with lower versions and was introduced in the latest version of support-v7. The list of 1 is implemented using ListView, and the list of 2 is implemented using RecyclerView. In addition, both of them have a set of Preferences, which are Item items in the list, which can meet various needs and can also be customized.

    Specific ideas:

    1. [Night Mode], [Settings] is just a Preference

    2. [Night Mode] The above divider is a PreferenceCategory

    3. with no content set
    4. Write *prefs.xml according to your needs

    The layout of p.s.Preference can be set by calling the interface or modifying themes.xml (style)

    Specific usage:

    • Official Document: PreferenceFragment

    p.s. For more usage, please Google it.

    reply
    0
  • 阿神

    阿神2017-04-17 18:03:10

    For linearlayout, there are showpiders. You can download it from Baidu or Google. It’s very convenient. You don’t need to write View as a dividing line.

    reply
    0
  • Cancelreply