【问题标题】:How to decrease the Width and Height of CheckBox in Android如何在 Android 中减小 CheckBox 的宽度和高度
【发布时间】:2012-12-07 21:44:11
【问题描述】:

谁能告诉我如何减少 CheckBox 的宽度和高度以便在 Android 中显示非常小的 CheckBox ?

提前致谢,

【问题讨论】:

    标签: android android-manifest


    【解决方案1】:

    只需像使用普通按钮一样使用 setWidth(w) 和 setHeight(h) 函数。

    【讨论】:

      【解决方案2】:

      setWidth(int)setHeight(int) 因为 CheckBox 扩展 CompoundButton 扩展 Button

      尝试参考this tutorial

      或者尝试通过 XML 更改它:

      <CheckBox 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content"
          android:text="new checkbox" 
          android:background="@drawable/my_checkbox_background"
          android:button="@drawable/my_checkbox" />
      

      【讨论】:

      • 我通过代码创建了 CheckBox 并使用了 setWidth() 和 setHeight() 方法,但宽度和高度仍然没有改变。还有其他解决方案吗?
      【解决方案3】:

      更新:这仅适用于 API 17 以后...


      根据我对这个问题的回答: - how can we reduce the size of checkbox please give me an idea


      CheckBox 的高度来自 TEXT 和图像。

      在您的 XML 中设置这些属性:

      android:text=""
      android:textSize="0sp"
      

      当然,这仅在您不想要文本时才有效(为我工作)。

      没有这些变化,CheckBox 让我的形象有了很大的优势,正如乔所说的那样

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-05-18
        • 1970-01-01
        • 1970-01-01
        • 2023-01-23
        • 2015-11-24
        • 1970-01-01
        • 2016-07-12
        相关资源
        最近更新 更多