【问题标题】:Android - Adjust button height by checkbox height?Android - 通过复选框高度调整按钮高度?
【发布时间】:2012-02-14 14:23:18
【问题描述】:

我有一个ListView,其中一行包含ButtonCheckBox 和多行TextView。 xml布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
               android:layout_width="fill_parent"
               android:layout_height="fill_parent"
               android:layout_centerVertical="true">

    <Button android:id="@+id/open"
              android:layout_height="wrap_content"
              android:layout_width="wrap_content"
              android:src="@drawable/play"
              android:text="Play"
              android:layout_centerVertical="true"
           />

    <CheckBox android:id="@+id/check"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_centerVertical="true"
             android:layout_toRightOf="@id/open"
           />

    <TextView android:text="@+id/label"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:id="@+id/label"
             android:textSize="16px"
             android:layout_toRightOf="@id/check"
             android:paddingLeft="4px"
           />

</RelativeLayout>

ListView的截图:

如何使用复选框高度调整按钮高度?

【问题讨论】:

  • 开始下载按钮的 XML 是什么?
  • 开始下载按钮和列表视图通常位于某种 LinearLayout AFIK 中,因此您的 LinearLayout 可能有问题。

标签: android view size


【解决方案1】:

查看相对布局的 ALIGN_TOP 和 ALIGN_BOTTOM 属性。您可以将按钮的顶部和底部与复选框的顶部和底部对齐。

【讨论】:

    【解决方案2】:

    您可以将自定义样式设置为具有比默认值更低的填充值的按钮。
    您可以为按钮设置边距。
    您可以为按钮高度设置一个固定的 DP 值。

    【讨论】:

      【解决方案3】:

      已解决

      <Button android:id="@+id/open"
              ...    
              style="?android:attr/buttonStyleSmall"
              ...
              />
      

      【讨论】:

        猜你喜欢
        • 2014-03-08
        • 2018-11-03
        • 1970-01-01
        • 2014-11-15
        • 1970-01-01
        • 2010-12-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多