导航:首页 > 操作系统 > 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线性布局相关的资料

热点内容
编程珠玑笔记 浏览:278
结束命令行 浏览:268
力学原理pdf 浏览:733
宏定义编译后不变 浏览:401
如何搞免费服务器 浏览:210
神经系统pdf 浏览:669
如何查看服务器上的数据库服务器 浏览:193
压缩机型号v代表什么 浏览:56
旅游类源码 浏览:866
电脑服务器类型怎么设置 浏览:234
pdf炒股 浏览:790
服务器地址缺少端口号什么意思 浏览:534
下载需要解压的小说用哪个软件 浏览:538
广东分布式服务器云主机 浏览:587
服务器忙打不开怎么办 浏览:19
tif压缩软件 浏览:417
程序员那么可爱陆漓上班第1天 浏览:952
macbookair自带什么app 浏览:705
如何关了加密的软件 浏览:586
程序员p2p待遇 浏览:923