Android怎么让LinearLayout的两个按钮之间存在一些间隔

Android怎么让LinearLayout的两个按钮之间存在一些间隔,第1张

可以按照以下代码进行尝试:

<?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:graviity="center|top" 那么这个控件中的子控件位于该控件的中心位置靠上的部位。

若设置一个控件为android:layout_gravity="center|top" 那么这个控件位于他父控件的中心位置靠近上的部位,是对这个控件本身位置的 *** 作。

android:layout_marginBottom:离某元素底边缘的距离

android:layout_marginLeft:离某元素左边缘的距离

android:layout_marginRight:离某元素右边缘的距离

android:layout_marginTop:离某元素上边缘的距离

Android中两个Button可以使用线性布局LinearLayout来包含。

控件之间的间距有两种设置:

android:layout_margin="10dp" 外边距

android:padding="10dp" 内边距

在Button中将android:layout_margin="0dp" android:padding="0dp"

即将内外两个间距都设置为0即可


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/tougao/7752963.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-09
下一篇 2023-04-09

发表评论

登录后才能评论

评论列表(0条)

保存