【问题标题】:android:button on RadioButton not workandroid:RadioButton 上的按钮不起作用
【发布时间】:2016-07-26 13:22:55
【问题描述】:

我需要自定义 RadioButton 并在我的 XML 中:

        <RadioButton
            android:id="@+id/radBorderBottom"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_marginLeft="8dp"
            android:layout_marginRight="8dp"
            android:layout_weight="1"
            android:background="@drawable/toggle_center_selector"
            android:button="@drawable/ic_border_bottom"   //not see
            android:checked="true"
            android:gravity="center"
            android:onClick="onSeletedPosition" />

我在这里只看到背景,看不到按钮。 P/s:当我应用最新的 Aviary SDK 时会出现此问题。但是在Activity中却包含了这个XML我不改。

【问题讨论】:

    标签: android android-radiobutton aviary adobecreativesdk


    【解决方案1】:

    在您的 drawable 文件夹中创建一个 button.xml 文件。

    <?xml version="1.0" encoding="utf-8"?>
    

    <item android:drawable="@drawable/apptheme_btn_radio_off_t_holo_light" android:state_checked="false"/>
    <item android:drawable="@drawable/apptheme_btn_radio_on_t_holo_light" android:state_checked="true"/>
    <item android:drawable="@drawable/apptheme_btn_radio_off_t_holo_light"/>
    

    最后设置 android:button="@drawable/button

    希望对你有帮助..

    【讨论】:

      【解决方案2】:

      将您的代码放在 RadioGroup 中

      <RadioGroup> <RadioButton /> </RadioGroup>

      【讨论】:

      • 是的,我的代码也是这样。当我更改代码时,一切看起来都很好。我不明白为什么 Aviary 会犯这个错误。
      【解决方案3】:

      试试这个代码

      <RadioButton
                  android:id="@+id/radBorderBottom"
                  android:layout_width="wrap_content"
                  android:layout_height="5dp"
                  android:layout_marginLeft="8dp"
                  android:layout_marginRight="8dp"
                  android:layout_weight="1"
                  android:background="@drawable/ic_launcher"
                  android:button="@android:color/transparent"
                  android:checked="true"
                  android:gravity="center"
                  android:onClick="onSeletedPosition" />
      

      【讨论】:

      • 对不起,我需要在 xml 中更改按钮,当我更改代码时,一切看起来都很好。我不明白为什么 Aviary 会犯这个错误。
      【解决方案4】:

      尝试升级到最新版本的 Creative SDK Image Editor(以前的 Aviary)。

      在旧版本的 SDK 中,某些布局元素的命名空间不正确,可能会导致此类问题。

      从哪里开始

      1. You can find out how to get the latest version of the SDK here
      2. You can find out how to integrate the latest version of the Image Editor here

      【讨论】:

        猜你喜欢
        • 2021-05-31
        • 2019-01-23
        • 2015-11-03
        • 1970-01-01
        • 2019-09-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多