你好,游客 登录 注册 搜索
背景:
阅读新闻

Android 布局(线性布局、相对布局)

[日期:2017-04-10] 来源:Linux社区  作者:bhlr [字体: ]

Android 布局(线性布局、相对布局)

一、线性布局(LinearLayout)

<LinearLayout
****
</LinearLayout>
1. orientation(布局方向)value=0
  horizontal:水平 value=1
通过改变的Linear Layout的Orientation布局方向属性可以改变View的排列方式。
2.配对父视图:match_parent
  Layout_width/height的属性:
    fixed dp values(固定大小的宽高值)
    wrap_cntent(宽、高包含内容就可以)
    match_parent(匹配父视图的宽、高)
3.布局帐View的均衡分布:LinearLayut_weight(给每个View分配权重)
  不管设备屏幕大小怎样,都是按照权重去平分屏幕

    eg:
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"//想垂直平分屏幕就要设置height=“0dp”
android:layout_weight="1"
android:background="#4CAF50"
android:textSize="60dp"
android:text="Hello World!" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:textSize="60dp"
android:background="#2196F3"
android:text="Hello World!"
/>

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="I Love Code !"
android:textSize="60dp"
android:id="@+id/button"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="96dp" />

效果如下:

以上就是线性布局的精要了、、、、、、

二、相对布局(RelativeLayout)

1.相对布局:父相对android :Layout_alignParent Top="true /false"

  _align Parent bottom/_align Parent Left/align Parent left/

  垂直居中:android :Layout_CenterVertical=“true”

  ID:Android:id=

  Layout

padding:内部(VIew自己处理)

margin:框架外部到边缘(View Group处理)

以上就是1B的学习了。

更多Android相关信息见Android 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=11

本文永久更新链接地址http://www.linuxidc.com/Linux/2017-04/142657.htm

linux
相关资讯       Android布局 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款