Android ImageView

  

如上图,drawable中不只是可以放bitmap  还可以定制不同形状

 

1 <?xml version="1.0" encoding="utf-8"?>
2 <shape xmlns:android="http://schemas.android.com/apk/res/android" >
3     <!-- 圆角矩形实形 -->
4     <corners android:radius="50dp"/>
5    <!--实体颜色 -->   
6     <solid android:color="#336699"/>
7 
8 </shape>

 

然后到layout中布局ImageView

 1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 2     android:layout_width="match_parent"
 3     android:layout_height="match_parent"
 4     android:orientation="vertical" >
 5     
 6     <TextView 
 7         android:layout_width="match_parent"
 8         android:layout_height="wrap_content"
 9         android:layout_margin="20dp"
10         android:padding="10dp"
11         android:gravity="center"
12         android:background="@drawable/btn"
13         android:text="登录"
14         android:textColor="@android:color/white"/>
15 
16     <EditText
17         android:layout_width="match_parent"
18         android:layout_height="wrap_content"
19         android:padding="10dp"
20         android:text="111"/>
21     <!-- 去掉默认的background或者button    @null -->
22      <EditText
23         android:layout_width="match_parent"
24         android:layout_height="wrap_content"
25         android:background="@null"
26         android:padding="10dp"
27         android:text="222"/>
28      <!-- 画一根线 -->
29      <View
30          android:layout_width="match_parent"
31          android:layout_height="3px"
32          android:layout_margin="5dp"
33          android:background="@android:color/darker_gray"/>
34      
35      <!-- android:src="@drawable/about" 引用图片资源 -->
36      <!-- android:adjustViewBounds="true"  拉伸按原图宽高比 -->
37      <!--android:scaleType="fitXY" 拉伸图片 -->
38      <ImageButton
39          android:layout_width="match_parent"
40          android:layout_height="wrap_content"
41          android:background="@null"
42          android:src="@drawable/about"
43          android:adjustViewBounds="true"
44          android:scaleType="fitXY"/>
45     
46 </LinearLayout>

效果图如下:

 

posted on 2016-09-27 20:20  语风6649  阅读(183)  评论(0编辑  收藏  举报

导航