【问题标题】:RadioButton in ListView ripple effectListView 中的 RadioButton 波纹效果
【发布时间】:2021-07-21 01:22:21
【问题描述】:

RadioButton 涟漪效应有问题。我想要得到这个:I have ripple in full background of list item

但我这个:I have ripple only around mark

我该如何实现?

【问题讨论】:

    标签: android listview radio-button material-design ripple-effect


    【解决方案1】:

    在 itemView 上应用单击侦听器,并在该侦听器中选中单选按钮 对或错。将 backgroundTint 更改为所需的单选按钮颜色。

    【讨论】:

    • 不,我想改变波纹效果的形状,而不是颜色。
    【解决方案2】:

    涟漪效果可用于 API 级别 21+,您可以将其应用于单选按钮 android:background="?android:attr/selectableItemBackground" 每个按钮

    <RadioGroup
        android:id="@+id/radiogroup"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    
        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="?android:attr/selectableItemBackground"
            android:text="Option number one" />
    
        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="?android:attr/selectableItemBackground"
            android:text="Option number two" />
    </RadioGroup>
    

    【讨论】:

    • 不幸的是,它对我不起作用。它没有效果。
    【解决方案3】:

    ListView 中使用CheckedTextViewSINGLE_CHOICE_MODE 参数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-20
      • 2017-05-01
      • 2011-11-30
      • 1970-01-01
      相关资源
      最近更新 更多