|
No.
|
配置属性名称
|
对应方法
|
描述
|
|
1
|
android:maxHeight
|
public void setMaxHeight (int maxHeight)
|
定义图片的最大高度
|
|
2
|
android:maxWidth
|
public void setMaxWidth (int maxWidth)
|
定义图片的最大宽度
|
|
3
|
android:src
|
public void setImageResource (int resId)
|
定义显示图片的ID
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<ImageView
android:layout_width="wrap_content"//宽度包裹内容
android:layout_height="wrap_content"//高度包裹内容
android:src="@drawable/bg"//设置图片
/>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/abc"
/>
</RelativeLayout>
从零开始学android<ImageView和ImageButton的使用.十.>,布布扣,bubuko.com
从零开始学android<ImageView和ImageButton的使用.十.>
原文:http://blog.csdn.net/u013616976/article/details/23311587