我在一個 Android 應用程式上作業,我需要根據應用程式設計指南實施過濾器。
有2種過濾器:
- 帶有圖示
- 沒有圖示
過濾器可以選擇/取消選擇(或選中/取消選中)
每個案例都可以在這里看到:

過濾器將通過GridView多行的 3 列顯示。
我想知道哪個原生控制元件更適合實作這一點?
我嘗試使用具有引數的
而檢查狀態如下所示:

對于沒有圖示的按鈕,您根本不會為頂部指定可繪制物件。
這些不是您想要的顏色,但這就是想法。
uj5u.com熱心網友回復:
我終于通過 aMaterialButton和android:checkable屬性實作了這一點:
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.button.MaterialButton
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@ id/CheackableCell"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:icon="@drawable/ic_carwash"
app:iconGravity="textTop"
app:iconPadding="12dp"
tools:text="Car Wash"
android:textAlignment="gravity"
android:gravity="top|center"
android:paddingBottom="4dp"
android:checkable="true"/>
它非常接近 Cheticamp 給出的解決方案。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/411762.html
標籤:
