布局TextView和EditText区别,layout_width和lay_weight区别--Android Studio
1. TextView控件是文本表示控件,主要功能是向用户展示文本的内容,它是不可编辑的,如设置标题;EditText控件是编辑文本控件,主要功能是让用户输入文本的内容,它是可以编辑的。
每一个控件都有着与之相应的属性,通过选择不同的属性,给予其值,能够实现不同的效果。
2. layout_width属性值设置为wrap_content时,获得的空间仅够描绘自身,还有额外的空间。layout_weight的属性值进行额外的空间分配。
如果layout_width="0dp",则只考虑layout_weight属性值。
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"> <Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/crime_date"
android:layout_weight="1"
/>
<CheckBox
android:id="@+id/crime_solved"
android:text="@string/crime_solved_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_weight="1"/>
</LinearLayout>
如代码:LinearLayout有两个控件,Button 和CheckBox. 第一步查看layout_width属性值(竖直方向则查看layout_height)。因为设置为wrap_content时,获得的空间仅够描绘自身,还有额外的空间。
第二步LinearLayout依据layout_weight的属性值进行额外的空间分配。两个子组件属性值同为1。因为均分了同样大小的额外空间。若设Button的layout_weight的值为2,则将获得2/3的额外空间,
CheckBox组件获得剩余的1/3。
布局TextView和EditText区别,layout_width和lay_weight区别--Android Studio的更多相关文章
- 将Android Studio默认布局ConstraintLayout切换成LinearLayout
将Android Studio默认布局ConstraintLayout切换成LinearLayout 大部分人初次使用google android 扁平化布局ConstraintLayout都 ...
- Android控件——TextView,EditText
TextView: 显示文本控件 EditText 输入文本框 1.TextView常用属性:
- Android入门(三):使用TextView、EditText 和Button接口组件
我使用的IDE是Android Studio 2.1,虽然使用Eclipse也可以进行Android的开发,但是网上的大神大都推荐Android Studio,愿意了解的朋友可以参考知乎上关于Andr ...
- Android 在界面中显示以及输入文本信息 TextView和EditText
Android控件之TextView和EditTextTextView:显示文本框控件EditText:输入文本框TextView和EditText的常用属性TextView控件的常用属性androi ...
- android studio 布局
1) 可见(visible)XML文件:Android:visibility="visible"Java代码:view.setVisibility(View.VISIBLE); 2 ...
- Android Studio 2.2新增布局——ConstraintLayout完全解析
,但是Button并没有紧贴到布局的最右侧,这是为什么呢?实际上,Android Studio给控件的每个方向上的约束都默认添加了一个16dp的间距,从Inspector上面也可以明显地看出来这些间距 ...
- android textview字体加粗 Android studio最新水平居中和垂直居中
android textview字体加粗 Android studio最新水平居中和垂直居中 Android中字体加粗在xml文件中使用android:textStyle=”bold”但是不能将中文设 ...
- Android studio 基本布局-底部按钮
在使用Android studio 的时候,准备弄的基本的布局出来,底部按钮,按了中间会显示. 来上代码: 页面menu_main.xml 这里弄控件的浮动耗费了点我的时间.原因是因为对其各种问题, ...
- 设置Android Studio工程布局文件的默认布局
每次创建新的工程后,布局文件的的布局总是ConstraintLayout,如何更改? 进入Android Studio安装目录,用文本编辑器打开文件plugins\android\lib\templa ...
随机推荐
- svn cleanup 执行失败时,可以勾选 break locks,
- BZOJ 3144: [Hnoi2013]切糕
3144: [Hnoi2013]切糕 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 1495 Solved: 819[Submit][Status] ...
- MongoDB数据库的CURD的一些基本语句
from:http://www.data321.com/shujuku/20160514417/addToSetQianMianBuXuYaoJinXing 插入文档: SQL语句: INSERT I ...
- [LeetCode] Nested List Weight Sum 嵌套链表权重和
Given a nested list of integers, return the sum of all integers in the list weighted by their depth. ...
- [LeetCode] Read N Characters Given Read4 II - Call multiple times 用Read4来读取N个字符之二 - 多次调用
The API: int read4(char *buf) reads 4 characters at a time from a file. The return value is the actu ...
- const 引起的BUG
今天白天出现了碰见了一个问题,隐藏得比较深,这里记录一下. 初衷很简单,就是要更改改一个数据库的链接名,这个链接名是放在数据层public const string connDB="conn ...
- QT基本操作
QApplication(argc,argv[]) AAA *XX=new AAA();AAA代表要创建的控件类型,XX表示该控件上的命名.
- insmod模块的几种常见错误
1. 与内核版本不一致 嵌入式开发时,模块编译时需要制定内核的路径,内核的版本信息会加入到模块文件中,如果目标板上运行的内核与模块中包含的内核版本对不上,加载就会出错,报如下错误: insmod i ...
- NBUT 1457 莫队算法 离散化
Sona Time Limit:5000MS Memory Limit:65535KB 64bit IO Format: Submit Status Practice NBUT 145 ...
- bzoj1251
1251: 序列终结者 Time Limit: 20 Sec Memory Limit: 162 MBSubmit: 3776 Solved: 1581[Submit][Status][Discu ...