在安卓中什么是线性布局,表格布局,相对布局???求详细答案,急急急!!!!
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励20(财富值+成长值)
2个回答
展开全部
线性布局(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>
分享
<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>
分享
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
线性布局有两种
横和竖
控件和控件的排列是按线性排列的
比如控件1再放控件就是控件1控件3等等
它们之间的位置是按着顺序排列的(形成一条线一样)
表格布局就是行x列的这种方式
然后根据你的需求将控件添加在哪行哪列这种
相对布局
控件的位置是相对于某个参照物放置的
比如相对某个控件多少距离
相对上方多少距离等等放置控件
横和竖
控件和控件的排列是按线性排列的
比如控件1再放控件就是控件1控件3等等
它们之间的位置是按着顺序排列的(形成一条线一样)
表格布局就是行x列的这种方式
然后根据你的需求将控件添加在哪行哪列这种
相对布局
控件的位置是相对于某个参照物放置的
比如相对某个控件多少距离
相对上方多少距离等等放置控件
更多追问追答
追问
你说的控件是什么意思
追答
构件知不知道
比如TextView这些显示在界面上的按钮啊等等
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询