我有一个自定义对话框有3个按钮,有时它只有一个按钮。当我有3个按钮时,LinearLayout
本身就适合这些按钮。但是,当我只有一个按钮时,它将整个宽度提供给一个按钮,使该按钮看起来太大。我想,如果只有一个按钮,它应该只需要一半的整个宽度可以或者应该换行的内容(按钮图像。)请参见下面的图像的参比LinearLayout中的按钮问题
1
A
回答
3
请参阅此XML文件,该文件与您的要求类似。只是知道去了不需要的按钮。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" android:weightSum="3" android:gravity="center_horizontal">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button"/>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button"/>
</LinearLayout>
1
在为了有一个按钮,最多一半需要
- 集机器人可用的屏幕宽度:weightSum =父“2”的LinearLayout
- 集android:layout_weight =“1”中的按钮
相关问题
- 1. 从按钮的LinearLayout
- 2. 按钮放置在LinearLayout中
- 3. 的LinearLayout问题
- 4. 按钮并排LinearLayout
- 5. WebView和按钮的LinearLayout
- 6. LinearLayout中的中心图像按钮
- 7. LinearLayout findViewById问题
- 8. Android linearLayout问题
- 9. LinearLayout问题[Android]
- 10. LinearLayout问题
- 11. linearlayout问题
- 12. HTML中的按钮问题
- 13. 删除LinearLayout中的按钮间距(Android)
- 14. LinearLayout中的Android按钮Fit Left
- 15. 按钮问题
- 16. 问题按钮
- 17. 销毁LinearLayout中一个按钮的另一个按钮
- 18. facebook按钮的问题喜欢按钮
- 19. Linearlayout重力问题?
- 20. Android按钮问题
- 21. 按钮CSS问题
- 22. Java按钮问题
- 23. PayPal按钮问题
- 24. ModalPopupExtender按钮问题
- 25. Android - 按钮问题
- 26. Fancybox按钮问题
- 27. iPhone按钮问题
- 28. controlgroup按钮问题
- 29. IE按钮问题
- 30. 垂直对齐按钮和垂直定向LinearLayout内的垂直定向LinearLayout的问题
请发表您的源 – 2012-04-10 07:49:57
我觉得杰森问:请张贴的XML为你的布局,使我们可以看看,并回答意味深长 – 2012-04-10 08:04:44
我不认为这个问题值得它得到了downvote。这是一个非常有效和清晰的问题。是的,在指出错误时可能需要XML,但我认为即使没有当前的布局实现,也可以给出几个很好的答案。请不要过于乐意与你的赞誉,人民! – dbm 2012-04-10 08:14:09