Android - 通过复选框高度调整按钮高度?
我有一个 ListView
,其中一行包含 Button
、CheckBox
和多行 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
的屏幕截图:
如何调整按钮高度复选框高度?
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
:
How can I adjust the button height with checkbox height?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(3)
查看相对布局的 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.
您可以将自定义样式设置为具有比默认值更低的填充值的按钮。
您可以设置按钮的边距。
您可以为按钮高度设置固定的 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.
已解决
SOLVED