【问题标题】:Applying star style to checkbox in Android将星形样式应用于Android中的复选框
【发布时间】:2012-07-13 01:30:02
【问题描述】:
style="?android:attr/starStyle" 

将此代码应用于复选框属性后,我无法查看该复选框。代码有错误吗?

【问题讨论】:

    标签: android checkbox android-widget styles android-xml


    【解决方案1】:

    发布您的完整 xml 文件。它对我有用:

    <CheckBox
        android:id="@+id/checkBox1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        style="?android:attr/starStyle"
        android:text="CheckBox" 
    />
    

    【讨论】:

      【解决方案2】:

      检查下面的代码可能对你有帮助...

      在您的布局文件中,您的复选框...

      <CheckBox
              android:id="@+id/Check"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginTop="20dp"
              android:layout_marginLeft="5dp"
              android:text="  Not connected "
              android:textSize="14sp"
              android:textStyle="bold"
              android:textColor="#ccc"
              android:clickable="true"
              android:focusable="true" 
              android:button="@drawable/check"/>
      

      在 R/drawable/check.xml 中 - 在这里使用你的星星图片而不是我的图片。

      <?xml version="1.0" encoding="UTF-8"?>
      
      <selector xmlns:android="http://schemas.android.com/apk/res/android">
          <item 
              android:state_checked="true" 
              android:state_window_focused="true"
              android:state_enabled="true"
              android:drawable="@drawable/check_on" />
      
          <item 
              android:state_checked="false" 
              android:state_window_focused="true"
              android:state_enabled="true"
              android:drawable="@drawable/check_off" />
      </selector>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-05-25
        相关资源
        最近更新 更多