xml布局文件
在文件夹res/layout中存放着xml格式的布局文件
布局方式主要是LinearLayout(线性布局) 、TableLayout(表格布局)、RelativeLayout(相对布局)
当然还有AbsoluteLayout、(绝对布局)、FrameLayout(帧布局)等等
他们之间也可以通过嵌套达到更好的界面效果
我按照个人的理解将常用的属性整理了一下
可能不科学 但我认为很实用。
控件为整体:
android:id 地址
android:width 宽度
android:height 高度
android:layout_width 宽(fill_parent/wrap_content)
android:layout_height 高(fill_parent/wrap_content)
android:layout_margin(Left/Top/Right/Bottom) 外边距(*dip)
android:layout_weight 比重
控件内容:
android:text 文本内容
android:textSize 文本大小
android:gravity 内容基本位置
android:background 背景色(RBG)
android:padding(Left/Top/Right/Bottom) 内边距(*dip)
android:singleLine 内容同行显示(true/false)
相对布局:
android:layout_above 下边与谁的上边对齐(id)
android:layout_below 上边与谁的下边对齐(id)
android:layout_toLeftOf 右边与谁的左边对齐(id)
android:layout_toRightOf 左边与谁的右边对齐(id)
android:layout_alignTop 上边与谁的上边对齐(id)
android:layout_alignBottom 下边与谁的下边对齐(id)
android:layout_alignLeft 左边与谁的左边对齐(id)
android:layout_alignRight 右边与谁的右边对齐(id)
android:layout_alignParentTop 上边与父控件的上边对齐(true/false)
android:layout_alignParentBottom 下边与父控件的下边对齐(true/false)
android:layout_alignParentLeft 左边与父控件的左边对齐(true/false)
android:layout_alignParentRight 右边与父控件的右边对齐(true/false)
android:layout_centerInParent 相对父控件居中(true/false)
android:layout_centerHorizontal 相对父控件水平方向居中(true/false)
android:layout_centerVertical 相对父控件垂直方向居中(true/false)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
下面给出我刚做好的注册页面
登录后复制
以上就是XML布局文件的代码案例分享的详细内容,更多请关注【创想鸟】其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。
发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2418934.html