基本组件之Textview的基本属性及功能

1.autolink 可选值(none,web,phone,email,map,all)设置一个URL连接,可以单击访问

[img]http://dl2.iteye.com/upload/attachment/0110/6335/5058bd4a-b8f6-37ef-896f-38c054f3f272.png[/img]

访问网页:

[img]http://dl2.iteye.com/upload/attachment/0110/6337/5d583d14-2166-3dc0-af80-7ab60075b30b.jpg[/img]

<TextView
android:id="@+id/autolink1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="30px"
android:autoLink="web"
android:gravity="center"
android:text="百度:https://www.baidu.com/?tn=SE_hldp05080_um1fa6j8"
android:layout_gravity="center"/>

发送邮件:

[img]http://dl2.iteye.com/upload/attachment/0110/6339/88c6ebbb-c75a-3587-8202-a5441fa93860.jpg[/img]

<TextView
android:id="@+id/autolink2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="30px"
android:autoLink="email"
android:gravity="center"
android:text="邮箱:1450901761@qq.com"
android:layout_gravity="center"/>

拨打电话:

[img]http://dl2.iteye.com/upload/attachment/0110/6341/6aaeeaec-0e9f-3c61-9fcf-70d202cfb242.jpg[/img]

<TextView
android:id="@+id/autolink3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="电话:13888888888"
android:textSize="30px"
android:autoLink="phone"
android:layout_gravity="center"/>
地图:
需要有地图软件才能使用。

2.使用以下方法设置图片在文本的位置
android:drawableTop=""
android:drawableBottom=""
android:drawableLeft=""
android:drawableRight=""

[img]http://dl2.iteye.com/upload/attachment/0110/6343/2bec0847-57d3-3a9d-96ef-97ec58446f08.jpg[/img]

<TextView
android:id="@+id/drawable1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="图片在下面"
android:textColor="#ffff0000"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:drawableBottom="@+drawable/img1"/>
<TextView
android:id="@+id/drawable2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="图片在上面"
android:textColor="#ffff0000"
android:layout_gravity="center"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:drawableTop="@+drawable/img1"/>
<TextView
android:id="@+id/drawable3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="图片在左面"
android:textColor="#ffff0000"
android:layout_gravity="center"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:drawableLeft="@+drawable/img1"/>
<TextView
android:id="@+id/drawable4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="图片在右面"
android:textColor="#ffff0000"
android:layout_gravity="center"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:drawableRight="@+drawable/img1"/>

3.使用android:gravity="" 设置文本在文本框的位置

[img]http://dl2.iteye.com/upload/attachment/0110/6345/20127030-1216-3e1d-8992-fa5248ba05bd.jpg[/img]

<TextView
android:id="@+id/gravity1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="lalalaalla"
android:background="#ffff00ff"
android:gravity="center|top"/>
<TextView
android:id="@+id/gravity2"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="lalalaalla"
android:background="#ffff6666"
android:gravity="center|bottom"/>
<TextView
android:id="@+id/gravity3"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="lalalaalla"
android:background="#ff66ff66"
android:gravity="center|left"/>
<TextView
android:id="@+id/gravity4"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="lalalaalla"
android:background="#ff999999"
android:gravity="center|right"/>
<TextView
android:id="@+id/gravity5"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="lalalaalla"
android:background="#ff992222"
android:gravity="center_vertical"/>
<TextView
android:id="@+id/gravity6"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="lalalaalla"
android:background="#ff997777"
android:gravity="clip_vertical"/>

4.使用android:singleLine="" 设置单行文本、多行文本

[img]http://dl2.iteye.com/upload/attachment/0110/6347/79400bca-c2f6-3887-bd64-222fd0207ee8.jpg[/img]

<TextView
android:id="@+id/singline1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="单行文本:在很久很久以前,有一位老人他带给我们一个苹果"
android:textColor="#f688" />

<TextView
android:id="@+id/singline2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="false"
android:textColor="#f985"
android:text="多行文本:在很久很久以前,有一位老人他带给我们一个苹果"/>

5.用户登录界面
布局:
<TableLayout ></TableLayout>
子类:
TableRow,TextView,EditText,Button

[img]http://dl2.iteye.com/upload/attachment/0110/6349/ec5ec880-a24a-31cf-97fb-7253cc6407cd.jpg[/img]

<TableRow android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView/>
<TextView android:text="用户名:"
android:id="@+id/textView1"
android:hint="输入账号"
android:layout_width="wrap_content"
android:textSize="24px"
android:layout_height="wrap_content"
/>
<EditText android:id="@+id/editText1"
android:textSize="24px"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:minWidth="200px"/>
<TextView />
</TableRow>
<TableRow android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView/>
<TextView android:text="密 码:"
android:id="@+id/textView2"
android:textSize="24px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<EditText android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="24px"
android:id="@+id/editText2"
android:inputType="textPassword"/>
<TextView />

</TableRow>
<TableRow android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView/>
<Button android:text="登录"
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button android:text="退出"
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView />
</TableRow>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值