7/100
lizong190060
new
今天的任务是我们来学习线性布局的嵌套,
如上图所示,今天我们做出的效果,第一担任是要创建好我们的项目,准备好相关的图片,和准备我们的字符串文件(strings.xml)里面我们要用到的东西。在图中我们可以看到用线性布局的功能是非常的强大的的课轻松的 就对界面进行一个划分,而且课以设计出较复杂的界面,这是是我们界面设计比较基础性的布局方式。
这里附上我们今天这个例子的代码,提供参考:
<?xml version="1.0" encoding="utf-8"?><LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#ffff00"
android:gravity="center"
android:orientation="horizontal"
>
<ImageView
android:id="@+id/imgsun"
android:layout_width="45dp"
android:layout_height="45dp"
android:src="@drawable/img01"/>
<ImageView
android:id="@+id/imgMoon"
android:layout_width="45dp"
android:layout_height="45dp"
android:src="@drawable/img02"/>
<ImageView
android:id="@+id/imgstar"
android:layout_width="45dp"
android:layout_height="45dp"
android:src="@drawable/img03"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:background="#00ff00"
android:gravity="center"
android:orientation="horizontal"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<Button
android:id="@+id/btnsun"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮1" />
<Button
android:id="@+id/btnmoon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮2" />
<Button
android:id="@+id/btnstar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮3" />
</LinearLayout>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/edtText1"
android:layout_margin="10dp"
android:background="#aaaaaa"
android:ems="10"
android:inputType="textImeMultiLine"
android:lines="5"
android:padding="10dp"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
android:text="线性布局的嵌套:横向的、纵向的的布局可以相互嵌套,形成比较负责的布局"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:background="#0000ff"
android:gravity="center"
android:orientation="horizontal"
>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#ff0000"
android:gravity="center"
android:orientation="vertical">
<Button
android:id="@+id/buttom1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮1"/>
<Button
android:id="@+id/buttom2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮2"/>
<Button
android:id="@+id/buttom3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮3"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:background="#0000ff"
android:gravity="center"
android:orientation="vertical">
<Button
android:id="@+id/buttom4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮4"/>
<Button
android:id="@+id/buttom5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮5"/>
<Button
android:id="@+id/buttom6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮6"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:background="#ffaaaa"
android:gravity="center"
android:orientation="horizontal">
<Button
android:id="@+id/buttom7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮7"/>
<Button
android:id="@+id/buttom8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮8"/>
</LinearLayout>
</LinearLayout>
二、总结
我们今天学的线性布局相对于其他的布局方法比较的简单,也是比较简单的,今天学的也没什么太大的逻辑性,说白了就是记住英文 单词,就是那么简单。
今天的任务是我们来学习线性布局的嵌套,
在这里插入图片描述
如上图所示,今天我们做出的效果,第一担任是要创建好我们的项目,准备好相关的图片,和准备我们的字符串文件(strings.xml)里面我们要用到的东西。在图中我们可以看到用线性布局的功能是非常的强大的的课轻松的 就对界面进行一个划分,而且课以设计出较复杂的界面,这是是我们界面设计比较基础性的布局方式。
这里附上我们今天这个例子的代码,提供参考:
<?xml version="1.0" encoding="utf-8"?><ImageView
android:id="@+id/imgsun"
android:layout_width="45dp"
android:layout_height="45dp"
android:src="@drawable/img01"/>
<ImageView
android:id="@+id/imgMoon"
android:layout_width="45dp"
android:layout_height="45dp"
android:src="@drawable/img02"/>
<ImageView
android:id="@+id/imgstar"
android:layout_width="45dp"
android:layout_height="45dp"
android:src="@drawable/img03"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<Button
android:id="@+id/btnsun"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮1" />
<Button
android:id="@+id/btnmoon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮2" />
<Button
android:id="@+id/btnstar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮3" />
</LinearLayout>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/edtText1"
android:layout_margin="10dp"
android:background="#aaaaaa"
android:ems="10"
android:inputType="textImeMultiLine"
android:lines="5"
android:padding="10dp"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
android:text="线性布局的嵌套:横向的、纵向的的布局可以相互嵌套,形成比较负责的布局"
/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#ff0000"
android:gravity="center"
android:orientation="vertical">
<Button
android:id="@+id/buttom1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮1"/>
<Button
android:id="@+id/buttom2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮2"/>
<Button
android:id="@+id/buttom3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮3"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:background="#0000ff"
android:gravity="center"
android:orientation="vertical">
<Button
android:id="@+id/buttom4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮4"/>
<Button
android:id="@+id/buttom5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮5"/>
<Button
android:id="@+id/buttom6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮6"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:background="#ffaaaa"
android:gravity="center"
android:orientation="horizontal">
<Button
android:id="@+id/buttom7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮7"/>
<Button
android:id="@+id/buttom8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮8"/>
</LinearLayout>
二、总结
我们今天学的线性布局相对于其他的布局方法比较的简单,也是比较简单的,今天学的也没什么太大的逻辑性,说白了就是记住英文 单词,就是那么简单。
帮助文档
快捷键
目录
标题
文本样式
列表
链接
代码片
表格
注脚
注释
自定义列表
LaTeX 数学公式
插入甘特图
插入UML图
插入Mermaid流程图
插入Flowchart流程图
插入类图
快捷键
Markdown 图标 快捷键
撤销
Ctrl /⌘+Z
重做
Ctrl /⌘+Y
加粗
Ctrl /⌘+B
斜体
Ctrl /⌘+I
标题
Ctrl /⌘+Shift +H
有序列表
Ctrl /⌘+Shift +O
无序列表
Ctrl /⌘+Shift +U
待办列表
Ctrl /⌘+Shift +C
插入代码
Ctrl /⌘+Shift +K
插入链接
Ctrl /⌘+Shift +L
插入图片
Ctrl /⌘+Shift +G
查找 Ctrl /⌘+F
替换 Ctrl /⌘+G
Markdown 4103 字数 186 行数 当前行 1, 当前列 0
HTML 3703 字数 146 段落