导航:首页 > 操作系统 > android线性布局

android线性布局

发布时间:2022-04-28 07:09:11

⑴ 在安卓中什么是线性布局,表格布局,相对布局求详细答案,急急急!!!!

线性布局(LinearLayout):在该标签下的所有子元素会根据orientation属性的值来决定是按行或者是按列来逐个显示。代码示例如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name" />

<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />

<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/test" />

</LinearLayout>
而相对布局,则是根据控件的相对位置而言,比如居于按钮的左侧或者右侧,示例如下:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/button1"
android:layout_alignTop="@id/button1"
android:text="@string/hello_world" />

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="@string/app_name" />

</RelativeLayout>
分享

⑵ Android中常用的五种布局

Android
布局是应用界面开发的重要一环,在Android中,共有五种布局方式分别是:
线性布局:LinerLayout
表格布局:TableLayout
相对布局:RelativeLayout
绝对布局:AbsoluteLayout
帧布局:FrameLayout

⑶ Android线性布局和表格布局及其相对布局 都适用于哪些场景

线性布局适用于控件呈线性排列场景(一个接着一个),此线性可以为横向的线性与纵向的线性。
表格布局适用于控件呈表格状分布,如m行n列,像HTML中的表单。
相对布局适用于另一控件或父控件,如在某个控件的左(右、上、下、中线对齐)或相对于父控件左(右、上、下、中线对齐)。

布局是可以互相嵌套的,如父控件(容器)是线性纵向布局,第一个子布局为相对,第二个是表格,第三个是线性...

Android布局的概念是从Swing及HTML的布局引申而来,与他们的排版都非常相似。

Android中还有一种绝对布局,与HTML中的DIV也非常相似,都是以绝对坐标定位的方式定位控件,但这种布局难以匹配Android不同的屏幕尺寸及不同分辨率,所以使用很少。

⑷ android 中线性布局怎样使控件居最右边

在控件中使用android:layout_gravity="right"

在线性布局中使用android:gravity="right"

前提条件是你的线性布局是vertical

否则就要用其他手段weight等

⑸ android的线性布局里有几个按钮,怎样控制按钮之间的间距啊

线性布局里面有两种情况,
1、垂直布局:在每个按钮上加上
//这个表示距上个控件5dp距下个控件5dp,相当于在上下各加了5dp的空白区域
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
2、水平布局:在每个按钮上加上
//这个表示距左边的控件5dp距右边的控件5dp,相当于在左右各加了5dp的空白区域
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"

⑹ android 用线性布局还是相对布局好

线性布局(LinearLayout):在该标签下的所有子元素会根据orientation属性的值来决定是按行或者是按列来逐个显示。代码示例如下: <LinearLayout xmlns:android="schemas/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/app_name" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /> <Button android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/test" /> </LinearLayout> 而相对布局,则是根据控件的相对位置而言,比如居于按钮的左侧或者右侧,示例如下: <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent"> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/button1" android:layout_alignTop="@id/button1" android:text="@string/hello_world" /> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:text="@string/app_name" /> </RelativeLayout>

阅读全文

与android线性布局相关的资料

热点内容
安卓手机刷新不了ins怎么办 浏览:435
python判断ip网段 浏览:362
穿越火线更新怎么开新服务器 浏览:315
腹部超声pdf 浏览:920
解压缩全能王能解压7z文件吗 浏览:248
python目录比较 浏览:645
公司程序员戴假发 浏览:345
oracle查看数据库状态命令 浏览:840
查汽车app叫什么 浏览:747
经济学英文pdf下载 浏览:798
python列表顺序 浏览:698
云南边缘计算服务器云服务器 浏览:105
小公司如何选择服务器 浏览:791
android指纹识别驱动 浏览:447
荣耀手机的系统有方舟编译器吗 浏览:629
单片机应用的论文 浏览:474
什么app可以查网购的真伪 浏览:444
培训班的程序员怎么样找工作 浏览:813
codeblocks编译器位数 浏览:447
bios加密怎么设置 浏览:350