android 界面布局-各个布局的属性介绍,sharedpreferences原理

本文介绍了Android界面布局,包括TableLayout、AbsoluteLayout、FrameLayout等,并详细讲解了各布局的属性及其使用注意事项。此外,还探讨了SharedPreferences的原理。
摘要由CSDN通过智能技术生成

TableLayout tableLayout = (TableLayout) findViewById(R.id.table01);

/*创建列对象*/

TableRow tableRow = new TableRow(this);

/*文本框对象*/

TextView temp = new TextView(this);

temp.setText(“text的值”);

/*将此文本添加到列中*/

tableRow.addView(temp);

android:stretchColumns=1,2,3,4 它的意思就是自动拉伸1,2,3,4列。

4.AbsoluteLayout ( 绝对布局 ) (里面可以放多个控件,并且可以自己定义控件的x,y的位置)

5.FrameLayout ( 帧布局 ) :(里面可以放多个控件,不过控件的位置都是相对位置)

在它里面的控件都是按后面的一个控件叠加在前一个控件上来显示的,所有元素都被放置在最左上角。 如:

<FrameLayout android:layout_width=“wrap_content”

android:layout_height=“wrap_content” android:layout_weight=“1”>

<ImageView android:id="@+id/iv1" android:layout_width=“wrap_content”

android:layout_height=“wrap_content” android:visibility=“invisible”

android:src="@drawable/lotusleaf">

<ImageView android:id="@+id/f1" android:layout_width=“wrap_content”

android:layout_height=“wrap_content” android:src="@drawable/frog_right"

android:visibility=“invisible”>

 

表示的是id为f1的控件叠加在id为iv1的控件上面显示

(LinearLayout 和 RelativeLayout 应该又是其中用的较多的两种。AbsoluteLayout 比较少用,因为它是按屏幕的绝对位置来布局的如果屏幕大小发生改变的话控件的位置也发生了改变。这个就相当于HTML中的绝对布局一样,一般不推荐使用 )

注意事项:

1 、各布局不要乱用各自的属性。比如把属于 AbsoluteLayout 布局的android:layout_xandroid:layout_y用到 LinearLayout 布局或 RelativeLayout 布局,或者把 RelativeLayout 布局的 below , rightof 等属性应用到其他布局中。这样做虽然不会报错,但这是白浪费感情的工作,根本达不到我们需要的效果。

2 、关于android:layout_width=“fill_parent” a_ndroid:layout_height=“wrap_content”_ ,这是对每个布局宽和高的设置。 wrap_content 可表示随着其中控件的不同而改变这个布局的宽度或高度,类似于自动设置宽和高, fill_parent 使布局填充整个屏幕,另外还有一种 match_parent ,它本质上和 fill_parent 一样,并从 API  Level8 开始替代 fill_parent

TextView 的属性 :

android:autoLink              //设置是否当文本为URL链接/email/电话号码/map时,文本显示为可点击的链接。可选值(none/web /email/phone/map/all)

android:autoText                   //如果设置,将自动执行输入值的拼写纠正。此处无效果,在显示输入法并输入的时候起作用

android:bufferType               //指定getText()方式取得的文本类别。选项editable 类似于StringBuilder可追加字符,也就是说getText后可调用append方法设置文本内容。spannable 则可在给定的字符区域使用样式

android:capitalize                  //设置英文字母大写类型。此处无效果,需要弹出输入法才能看得到,参见EditView此属性说明

android:cursorVisible              //设定光标为显示/隐藏,默认显示

android:digits                     /

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值