[英]How to position an XML element half in between two other elements?
在XML中有
<Button android:id="@+id/Btn1"
android:layout_height="50dp" android:layout_width="50dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
/>
将元素放置在屏幕顶部和底部之间的一半位置。
还有一种方法可以position a Button Btn2 right in between Btn1 and the top or buttom
地position a Button Btn2 right in between Btn1 and the top or buttom
屏幕position a Button Btn2 right in between Btn1 and the top or buttom
? 然后如何将Button Btn3 right half between Btn1 and Btn2
?
编辑:我需要在相对布局中谢谢
只需应用整个布局,不要错过下面的任何内容。 它将适用于所有屏幕尺寸的android手机。
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_height="fill_parent" android:id="@+id/linearLayout1" android:layout_width="fill_parent">
<LinearLayout android:id="@+id/linearLayout2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_vertical|center_horizontal">
<Button android:text="Button" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
</LinearLayout>
<LinearLayout android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/linearLayout4" android:gravity="center_horizontal">
<Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
</LinearLayout>
<LinearLayout android:id="@+id/linearLayout3" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="1" android:gravity="center_vertical|center_horizontal">
<Button android:text="Button" android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
</LinearLayout>
</LinearLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.