[英]How to gap between two buttons in LinearLayout
In my app two button arranged vertically in LinearLayout. 在我的应用中,两个按钮在LinearLayout中垂直排列。 i want to provide a gap between two buttons.
我想在两个按钮之间提供一个间隙。 Please provide a solution...
请提供解决方案...
my layout as follows 我的布局如下
<?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="wrap_content"
android:orientation="vertical"
android:padding="10dp"
>
<Button
android:id="@+id/btnAction1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/cool_button"
android:text = "HiText1"
/>
<Button
android:id="@+id/btnAction2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/cool_button"
android:text="HiText2"
android:layout_below="@id/btnAction1"
/>
</LinearLayout>
image 图片
thanks in advance 提前致谢
Add a margin (android:layout_marginTop="50dp") to the top of of the second button: 在第二个按钮的顶部添加一个边距(android:layout_marginTop =“ 50dp”):
<?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="wrap_content"
android:orientation="vertical"
android:padding="10dp"
>
<Button
android:id="@+id/btnAction1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/cool_button"
android:text = "HiText1"
/>
<Button android:layout_marginTop="50dp"
android:id="@+id/btnAction2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/cool_button"
android:text="HiText2"
android:layout_below="@id/btnAction1"
/>
</LinearLayout>
使用android:layout_marginTop="10dp"
在第二个按钮上使用android:layout_marginTop="10.0dip"
。
use this code for your second button 使用此代码作为第二个按钮
<Buttonandroid:id="@+id/btnAction2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/cool_button"
android:text="HiText2"
android:layout_marginTop="15dp"
/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.