Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Android按钮布局 – 在整个屏幕上并排显示两个按钮大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有两个按钮,我希望水平并排显示,但它们一起填充手机的水平长度.高度是包裹内容,这很好.我现在的问题是只显示一个按钮(在屏幕上伸展).

这是我的XML代码

<LinearLayout 
   android:id="@+id/page_buttons"
   android:orientation="horizontal"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:gravity="center_horizontal"

   >
   <Button
        android:id="@+id/prevButton"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="PrevIoUs"
   /> 

   <Button
        android:id="@+id/nextButton"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Next"
   />

解决方法

更改按钮XML以包含layout_weight属性
<Button android:id="@+id/nextButton"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:text="Next"/>

大佬总结

以上是大佬教程为你收集整理的Android按钮布局 – 在整个屏幕上并排显示两个按钮全部内容,希望文章能够帮你解决Android按钮布局 – 在整个屏幕上并排显示两个按钮所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。