Android的组件要去使用布局的灵活性并适应各种尺寸的屏幕,应使用wrap_content和match_parent控制某些视图组件的宽度和高度。使用wrap_content,系统就会将视图的宽度和高度设置成所需的最小尺寸以适应视图中的内容,而match_parent(在低于API级别8的级别中称为fill_parent)..
分类:
移动开发 时间:
2015-09-04 22:42:29
阅读次数:
252
CheckBox复选框
1.属性:android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"//复选框状态
具体在mainActivity.java中实现
package com.imooc....
分类:
移动开发 时间:
2015-08-31 10:15:18
阅读次数:
196
mTVText.setGravity(Gravity.CENTER);//左上角设置为:Gravity.LEFT|Gravity.TOP
//LinearLayout居中
LinearLayout.LayoutParamsparams=newLinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
params.gravity=Gravity.CENTER_HORIZONTAL;
//设..
分类:
其他好文 时间:
2015-08-30 17:53:23
阅读次数:
226
res/layout 中设置布局文件
hint属性:提示输入信息
text属性:与hint的区别---hint仅仅是提示;
text是实际的内容
讲布局xml文件引入到activity当中
setContentView(R.layout.main_activity);将布局文件与当前文件关联
wrap_content:包裹实际文本内容
fill_parent:当前控件铺满父类容器(2...
分类:
移动开发 时间:
2015-08-30 14:25:05
阅读次数:
155
android:gravity: 这个是针对控件里的元素来说的,用来控制元素在该控件里的显示位置。例如,在一个Button按钮控件中设置如下两个属性, android:gravity="left"和android:text="提交",这时Button上的文字“提交...
分类:
其他好文 时间:
2015-08-29 17:22:46
阅读次数:
136
1. 如在一个不满全屏的LinearLayout(设置属性为wrap_content方向上的动画)中 有三个控件 假设为 button1 button2 button3 (均同一层次)
这时对任何button设置动画不起作用或只在LinearLayout中起作用。
解决方案:获取LinearLayout布局 View 然后调用 bringtoFront() 从而占满余下全屏。详细理由如:
h...
分类:
其他好文 时间:
2015-08-19 23:42:39
阅读次数:
351
在组件中加入可以首先获得焦点
以TextView为例:
如下:
android:layout_width="100dp"
android:layout_height="wrap_content"
android:background="#ffcc00"
android:ellipsize="marquee"
...
分类:
移动开发 时间:
2015-08-19 20:35:32
阅读次数:
221
3.自动拨号,打开网页等功能:
注意不要忘了导入权限
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:autoLink="all"//设置链接的支持功能,all代表支持全部功能,还可以选择,也可以单独选
...
分类:
移动开发 时间:
2015-08-19 20:32:36
阅读次数:
154
在游戏时,不管是退出游戏还是选择战机,都要弹出一个对话框,需要以下代码按一个按钮弹出对话框Layout文件:(添加一个按钮)<Buttonandroid:id="@+id/button1"android:layout_width="fill_parent"android:layout_height="wrap_content"android:text="准备起飞"/>在Main..
分类:
移动开发 时间:
2015-08-16 23:27:49
阅读次数:
232
一、TextView 继承自View类,本质上就是一个文本编辑器,只是Android关闭它的编辑功能。把编辑文字的功能交给了它的子类——EditText。特殊之处:
1.通过设置ellipsize=marquee,可以实现“跑马灯”
android:width=”wrap_content”
android:focusable = “true”
android:singleline = “tr...
分类:
移动开发 时间:
2015-08-16 02:11:16
阅读次数:
221