Android - 通过复选框高度调整按钮高度?

发布于 2025-01-05 05:16:41 字数 1403 浏览 3 评论 0原文

我有一个 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 的屏幕截图:

Listview 的屏幕截图

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

I've got a ListView, one row of which contains Button, CheckBox and multiline TextView. The xml layout:

<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>

Screenshot of ListView:

Screenshot of Listview

How can I adjust the button height with checkbox height?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

屌丝范 2025-01-12 05:16:41

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

Check out the ALIGN_TOP and ALIGN_BOTTOM properties of relative layout. You can align the top and bottom of your button to the top and bottom of the check box.

再见回来 2025-01-12 05:16:41

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

You can set custom style to the button with lower padding values then the default one.
You can set margin for the button.
You can set a fixed DP value for the buttons height.

烟凡古楼 2025-01-12 05:16:41

已解决

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

SOLVED

<Button android:id="@+id/open"
        ...    
        style="?android:attr/buttonStyleSmall"
        ...
        />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文