Android控件開發之ImageView

ImageView以最簡單的方式顯示圖片,這也是佈局中使用圖片最常用的方式,可以讓您的程序變的生動活潑

ImaeView效果圖


本程序main.xml源碼

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"/>
<ImageView 
    android:id="@+id/imageview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/bg" 
    android:layout_gravity="center_vertical"/>

</LinearLayout>




本程序java源碼

package com.sx.ImageView;


import android.app.Activity;
import android.os.Bundle;


public class ImageViewActivity extends Activity 
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章