![](/img/trans.png)
[英]problem in adding image view between two vertical linear layout placed side by side in android studio
[英]Linear Layout with two buttons side by side - android
我在下面的layout.xml中有3個按鈕,它們出現在彼此的下方......
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dip" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:id="@+id/btn_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Car" />
<Button
android:id="@+id/btn_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Vehicle" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:id="@+id/btn_3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Bike" />
</LinearLayout>
</LinearLayout>
我想並排前兩個按鈕(btn_1和btn_2)。 誰能給我一個如何做到這一點的暗示?
非常感謝
只需將android:orientation="vertical"
更改為android:orientation="horizontal"
的布局,每件事情都能正常工作
最好的方法是進行布局,然后按下這個代碼
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/Button9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:text="@string/Home1"/>
<Button
android:id="@+id/Button11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="@string/NextL"/>
在這種形狀中你有兩個按鈕在同一行很容易:D
將“線性布局”方向“垂直”更改為“水平”。然后將兩個按鈕的重量均為1或2.按照您的意願,按鈕將平均排列。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.