Android类似设置列表分类显示

本文介绍了如何在Android应用中创建一个类似设置列表的界面,将设置项按类别分组显示。通过使用特定的布局文件和ScrollView,可以轻松实现这个功能,无需大量编写代码。详细步骤和布局代码供开发者参考。
摘要由CSDN通过智能技术生成

在设置界面有很多设置项,有时需要分类显示,如下所示,如设置项过多,还会用到ScrollView,这是一个很通用的界面,只需要设置一些图片和布局就能达到这种效果,不用写几行代码,下面就做下记录,方便自己或有需要的朋友使用。


布局文件 main_settings.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#eee"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="45dp"
        android:background="@drawable/title_bar"
        android:gravity="center_horizontal|center_vertical" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="设置"
            android:textColor="#ffffff"
            android:textSize="20sp" />
    </LinearLayout>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbarStyle="outsideOverlay" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/tv_info"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="14dp"
                android:background="@drawable/preference_first_item"
                android:clickable="true"
                android:drawableRight="@drawable/mm_submenu"
                android:paddingBottom="10dp"
                android:paddingLeft="20dp"
                android:paddingRight="20dp"
                android:paddingTop="10dp"
                android:text="个人信息"
                android:textColor="#000"
                android:textSize="17sp" />

            <TextView
                android:id="@+id/tv_card"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/preference_item"
                android:clickable="true"
                android:drawableRight="@drawable/mm_submenu"
                android:paddingBottom="10dp"
                android:paddingLeft="20dp"
                android:paddingRight="20dp"
                android:paddingTop="10dp"
                android:text="二维码名片"
                android:textColor="#000"
                android:textSize="17sp"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值