基本的UI控件和布局文件
来源:互联网 发布:淘宝上面买假证可信吗 编辑:程序博客网 时间:2024/05/16 05:15
文本控件
-TextView
-EditText
按钮控件
-Button
-ImageButton
状态开关按钮
-ToggleButton
单选与复选按钮
-CheckBox
-RadioButton
图片控件
-ImageView
时钟控件
-AnalogClock
-DigitalClock
日期与时间选择控件
-DataPicker
-TimePicker
布局文件:
LinearLayout和RelativeLayout
共有属性:
java代码中通过btn1关联次控件
android:id=”@+id/btn1”
控件宽度
android:layout_width=”80px” //”80dip”或”80dp”
android:layout_width =“wrap_content”
android:layout_width =“match_parent”
控件高度
android:layout_height=”80px” //”80dip”或”80dp”
android:layout_height =“wrap_content”
android:layout_height =“match_parent”
控件排布
android:orientation=”horizontal”
android:orientation=”vertical“
控件间距
android:layout_marginLeft=”5dip” //距离左边
android:layout_marginRight=”5dip” //距离右边
android:layout_marginTop=”5dip” //距离上面
android:layout_marginRight=”5dip” //距离下面
控件显示位置
android:gravity=”center” //left,right, top, bottom
android:gravity=”center_horizontal”
android:layout_gravity是本元素对父元素的重力方向。
android:layout_gravity属性则设置控件本身相对于父控件的显示位置
android:gravity是本元素所有子元素的重力方向。
android:layout_gravity=”center_vertical”
android:layout_gravity=”left”
android:layout_gravity=”left|bottom”
TextView中文本字体
android:text=”@String/text1” //在string.xml中定义text1的值
android:textSize=”20sp”
android:textColor=”#ff123456”
android:textStyle=”bold” //普通(normal), 斜体(italic),粗斜体(bold_italic)
定义控件是否可见
android:visibility=”visible” //可见
android:visibility=”invisible” //不可见,但是在布局中占用的位置还在
android:visibility=”gone” //不可见,完全从布局中消失
定义背景图片
android:background=”@drawable/img_bg” //img_bg为drawable下的一张图片
seekbar控件背景图片及最大值
android:progressDrawable=”@drawable/seekbar_img”
android:thumb=”@drawable/thumb”
android:max = “60”
仅在RelativeLayout中有效:
在父亲布局的相对位置
android:layout_alignParentLeft=”true” //在布局左边
android:layout_alignParentRight=”true” //在布局右边
android:layout_alignParentTop=”true” //在布局上面
android:layout_alignParentBottom=”true ” //在布局的下面
在某个控件的相对位置
android:layout_toRightOf=”@id/button1” //在控件button1的右边,不仅仅是紧靠着
android:layout_toLeftOf=”@id/button1” //在控件button2的左边,不仅仅是紧靠着
android:layout_below=”@id/button1 ” //在控件button1下面,不仅仅是正下方
android:layout_above=“@id/button1” //在控件button1下面,不仅仅是正下方
定义和某控件对奇
android:layout_alignTop=”@id/button1” //和控件button1上对齐
android:layout_alignBottom=”@id/button1” //和控件button1下对齐
android:layout_alignLeft=”@id/button1” //和控件button1左对齐
android:layout_alignRight=”@id/button1” //和控件button2右对齐
android:layout_centerHorizontal=”true” //水平居中
android:layout_centerVertical=”true”
android:layout_centerInParent=”true”
仅在LinearLayout中有效
设置控件在一排或一列中所占比例值
android:layout_weight=”1”
- 基本的UI控件和布局文件
- android(20)_基本的UI控件和布局文件知识要点
- android面试题目大全<第一部分>,android基本的UI控件和布局文件知识
- Android面试题:基本的UI控件和布局文件知识要点
- Cocos2d-x 3.9教程:10.使用CocosStudio的UI编辑器从UI文件中加载布局和控件
- Android 常用布局及基本UI控件
- Android02_Android常用布局及基本UI控件
- Android 常用布局及基本UI控件
- Android(UI)布局(文件)控件标签的通用属性
- Android 基本的UI布局
- Android API Guide学习和常用布局及基本UI控件
- Android02_Android API Guide学习和常用布局及基本UI控件
- Android02_Android API Guide学习和常用布局及基本UI控件
- Android02Android API Guide学习和常用布局及基本UI控件
- 【Android基础笔记02】 API Guide学习和常用布局及基本UI控件
- 【Android基础笔记03】 Android RelativeLayout相对布局和基本UI控件
- android自学第二天 Android API Guide学习和LinearLayout布局及基本UI控件
- android自学第三天 RelativeLayout相对布局和基本UI控件
- SVN使用教程之-分支/标记 合并 subeclipse
- 欢迎使用CSDN-markdown编辑器
- ActiveMQ入门实例
- 阅读 JAVA并发编程实战 (一)
- Android开发中常用ADB命令总结
- 基本的UI控件和布局文件
- 从单线程到多线程之线程通信
- opengl和osg的坐标系统
- oracle自定义函数
- Android中Snackbar的介绍以及使用
- iOS 下,UILable自适应高度的方法
- (学习笔记)android 5.0 系统去电流程状态判断(上)
- CRM系统主要业务流程思维导图
- Java学习感受