【问题标题】:Unchecking radio buttons in a Radio Group without the ripple animation在没有波纹动画的情况下取消选中 Radio Group 中的单选按钮
【发布时间】:2017-03-04 08:10:12
【问题描述】:

我有一个测验应用程序,它在文本视图中显示问题,并在带有 4 个单选按钮的单选组中显示 4 个答案。要转到下一个问题,用户必须单击“下一步”按钮。

当用户选择一个特定的单选按钮并单击“下一步”按钮时,我会用下一个问题及其答案重新填充我的 UI。在显示下一个问题之前,我使用 RadioGroup clearCheck() 清除单选按钮选择。

但是用户可以在 UI 中看到此选择更改。

我尝试将透明颜色设置为单选按钮背景,但这并没有解决问题。

我该如何解决这个问题?

【问题讨论】:

    标签: android


    【解决方案1】:

    你可以通过调用radioGroup.jumpDrawablesToCurrentState()来结束动画 在clearCheck()之后。

    【讨论】:

      【解决方案2】:

      尝试像这样添加您自己的可绘制单选按钮:

      quiz_radiobutton.xml:

      <?xml version="1.0" encoding="utf-8"?>
      <selector xmlns:android="http://schemas.android.com/apk/res/android">
              <item android:state_checked="false" android:drawable="@drawable/checkbox_outline" />
              <item android:state_checked="true" android:drawable="@drawable/checkbox_outline_checked" />
      </selector>
      

      然后,更改按钮中的可绘制对象:

      <android.support.v7.widget.AppCompatRadioButton
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:button="@drawable/quiz_radiobutton"
      />
      

      这将停用波纹动画。

      【讨论】:

        猜你喜欢
        • 2020-02-10
        • 2014-01-30
        • 1970-01-01
        • 1970-01-01
        • 2013-05-05
        • 1970-01-01
        • 2020-09-13
        • 2013-01-22
        • 1970-01-01
        相关资源
        最近更新 更多