zoukankan      html  css  js  c++  java
  • textView布局的一点体会

     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用到。

  • 相关阅读:
    DI的3种实现方式
    spring ioc的实现方式
    异常:This application has no explicit mapping for /error, so you are seeing this as a fallback.
    maven项目 集成SSM框架
    org.xml.sax.SAXParseException错误
    Redis在web中的应用
    上传下载文件实例(vsftp服务器+nginx)
    Redis的安装与启动
    修饰器-2
    修饰器练习
  • 原文地址:https://www.cnblogs.com/hixin/p/4185321.html
Copyright © 2011-2022 走看看