【问题标题】:Android:How to set Multiple button,edittext,etc [closed]Android:如何设置多个按钮、编辑文本等 [关闭]
【发布时间】:2013-01-11 22:31:51
【问题描述】:

如何在水平方向设置两个或多个按钮,这样所有按钮都按垂直形式排列。 请告诉xml中的编码。

【问题讨论】:

  • 您是否亲自尝试过,或者您希望我们只是……为您做?免费吗?

标签: android android-layout android-widget


【解决方案1】:

您需要将它们放在线性布局中并将方向设置为水平

 <LinearLayout 
       android:id="@+id/login_selectionButtonGroup"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:orientation="horizontal">
                <Button
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_gravity="center_horizontal"
                    android:text="Button 1"
                    android:layout_weight="1">
                </Button>
                <Button
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_gravity="center_horizontal"
                    android:text="Button 2"
                    android:layout_weight="1">
                </Button>
        </LinearLayout>

希望对你有帮助

【讨论】:

  • 是的,但我可以在 button1 和 button2 下获得另一个按钮吗?
  • 是的,复制答案中的布局应该有 button1 和 button2 和 button3 和 button 4 应该放在下面
  • @Keyser 加油,现在修好了肯定是整理的时候误删了
猜你喜欢
  • 1970-01-01
  • 2019-09-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多