码迷,mamicode.com
首页 > 其他好文 > 详细

textView布局的一点体会

时间:2014-12-25 20:26:49      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 3     android:layout_width="match_parent"
 4     android:layout_height="match_parent"
 5     android:orientation="horizontal" >
 6     <ImageView android:id="@+id/img"
 7         android:layout_width="80dp"
 8         android:layout_height="80dp"
 9         android:background="#00000000"
10         android:scaleType="fitCenter"
11         android:layout_margin="10dp"/>
12    
13     <TextView android:id="@+id/name"   
14         android:textSize="40sp"
15         android:gravity="center_vertical"
16         android:layout_width="match_parent"
17         android:layout_height="match_parent"/>
18      
19 </LinearLayout>

listview的item,必须使用 android:layout_width="match_parent"
        android:layout_height="match_parent"/>

gravity才生效

ImageButton 是带图标的Button控件,有src的属性,也就是设置他的图标,也有一个所有控件公有的属性background, 这个也可以设置它的“图标”。
其实,src才是设置图标,而background只是设置背景。
如果控件的大小是100*100 图片资源是80*80的话,那么用src,图片就会居中显示,如果使用background那么图片就会被拉伸充满控件。
重要的是,background是底层的图片资源,src是覆盖在background上面的资源,他们可以叠加使用,实现选中的效果。在ActivityGroup用到。

textView布局的一点体会

标签:

原文地址:http://www.cnblogs.com/hixin/p/4185321.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!