如何设置两个按钮的宽度各占屏幕的一半

多鱼的夏天 2010-08-24 03:54:04
LinearLayout布局内有两个按钮,如何设置两个按钮的宽度各占屏幕的一半
...全文
2588 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
纠结的木棉花 2010-08-25
  • 打赏
  • 举报
回复
可以直接谁知它的width=“1/2pix”
sike200008 2010-08-25
  • 打赏
  • 举报
回复
帮定吧
panxq0809 2010-08-25
  • 打赏
  • 举报
回复
设置两个按钮属性
android:layout_weight="1"
多鱼的夏天 2010-08-25
  • 打赏
  • 举报
回复
可以用设置背景图来实现,不知道还有没有其他方法
obiwong 2010-08-25
  • 打赏
  • 举报
回复

<LinearLayout>
<Button android:layout_height="wrap_content"
android:layout_width="fill_parent" android:layout_weight="1"/>

<Button android:layout_height="wrap_content"
android:layout_width="fill_parent" android:layout_weight="1"/>
</LinearLayout>
forgottenp 2010-08-25
  • 打赏
  • 举报
回复
哦,这个刚刚看到过,就是layout_weight设置权重的问题~!~

http://blog.csdn.net/trampou/archive/2010/07/21/5752533.aspx
f8376904110 2010-08-25
  • 打赏
  • 举报
回复
android:layout_weight="1",这个很重要,不只是这样的用法,慢慢试就会知道。这个我很喜欢用。
云台095 2010-08-25
  • 打赏
  • 举报
回复
按2楼的说法
<!-- BUTTON菜单条 -->
<LinearLayout android:id="@+id/MainFace_AddUBiLinearLayout02"
android:orientation="horizontal" android:layout_alignParentBottom="true"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:weightSum="2">

<ImageButton android:text="@string/MainFace_String_OK"
android:id="@+id/MainFace_AddUBiButton01" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_weight="1"
android:src="@drawable/button_sure" android:background="#00000000">
</ImageButton>
<ImageButton android:text="@string/MainFace_String_BACK"
android:id="@+id/MainFace_AddUBiButton02" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_weight="1"
android:src="@drawable/button_back" android:background="#00000000">
</ImageButton>

</LinearLayout>
william_ycyh 2010-08-25
  • 打赏
  • 举报
回复
得到屏幕的宽度 直接设置width=“” 就行了

80,349

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧