實現類似主流 App(QQ、微信)的設置頁面:分組卡片、圓角邊框、圖標+標題+右側箭頭,支援長列表滾動。
製作一張包含圓角的 .9.png 背景圖,指定可拉伸區域與內容區域,設置給每個設置項的容器(如 TableRow)。優點:性能好、適配性強、無過度繪製。

<shape xmlns:android="https://schemas.android.com/apk/res/android">
<solid android:color="@android:color/white" />
<corners android:radius="8dp" />
<stroke android:width="1px" android:color="#ddd" />
</shape>
適用於簡單矩形圓角,複雜陰影/漸變較難實現。
<RelativeLayout android:background="#ffefebe7">
<!-- 頂部標題欄 -->
<RelativeLayout android:id="@+id/top_relative"
android:background="#106184"
android:layout_height="50dp">
<TextView android:text="設置" ... />
</RelativeLayout>
<!-- 可滾動內容區 -->
<ScrollView android:layout_below="@id/top_relative">
<LinearLayout android:orientation="vertical" android:padding="10dp">
<!-- 分組 1 -->
<TableLayout>
<TableRow android:background="@drawable/more_item_press">
<TextView android:drawableLeft="@drawable/mylike"
android:text="我的設置" />
<ImageView android:src="@drawable/ic_arrow" />
</TableRow>
</TableLayout>
<TextView android:text="我的設置" android:textColor="#888888" /> <!-- 分組標題 -->
<!-- 分組 2 -->
<TableLayout>
<TableRow android:background="@drawable/more_itemtop_press">
...
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
ScrollView 包裹垂直 LinearLayout 應對項目較多情況TableLayout + TableRow 實現等寬佈局more_itemtop_press(頂部圓角),尾項用 more_itembottom_press(底部圓角),單項則用全圓角背景TextView 的 drawableLeft 顯示圖標,drawablePadding 控制間距目前推薦使用 RecyclerView + CardView 實現,配合 MaterialCardView 可輕鬆實現圓角、陰影、Ripple 效果,代碼更簡潔且性能更優。