何谓布局?布局就是版面配置,而就如同制作公告栏一样,有着不同的排版方式。
接下来我会对LinearLayout、RelativeLayout、ConstraintLayout、TableLayout、FrameLayout、AbsoluteLayout
等六种布局进行分析,
得知布局间的差异後,
就能够更容易选择要使用的布局方式。
LinearLayout(线性布局)
可分为水平(horizontal)及垂直(vertical),分别使元件由左至右,亦或是由上到下排列,
在线性布局当中,可使用巢状的方式,
在水平的LinearLayout中放置垂直的LinearLayout,
或是在垂直的LinearLayout中放置水平的LinearLayout,
使整体更加灵活。
以下使用四个button示范如何在水平的LinearLayout中放置垂直的LinearLayout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
tools:context=".MainActivity">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A"
android:textSize="30dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="B-1"
android:textSize="30dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="B-2"
android:textSize="30dp" />
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="C"
android:textSize="30dp" />
</LinearLayout>
执行後的结果如图
>>: Day 10 利用 Cloudflare 来管理你的网域和子网域
绘制简易折线图 基础 座标刻度设定 多组数据应用 图例 legend() 在图表上标记文字 绘制散...
今天要讲的是怎麽把物件里的东西印出来 昨天我们使用了物件这个资料型态 那我们看看怎麽印出来吧~ va...
纪录了一下学习 SQLALchemy 的过程,如果有错误再请各位大神指教 一、套件安装 pip in...
Hello 大家, 废话不多说赶紧赶紧进入主题吧! 今天从叫车开始说起~ 这个动作要设定的参数有三个...
在继续实作 domain layer 之前,我们会介绍一个方便日常开发的工具:Flipper。 An...