目前只知道2种方法,第一种是通过 设置 和屏幕的边距 第二种 是设立 把ImageView套在LinearLayout 里边然后再设置LinearLayout的位置 我会把起决定性作用的属性用红色标出来不多废话了 大家看看就知道了。
[color=green]
方法一[/color]
<?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"
>
<ImageView
android:id="@+id/spaceshipImage"
[color=red]android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="151px"
android:layout_marginBottom="151px"
android:layout_marginLeft="96px"
android:layout_marginRight="96px"[/color]
android:src="@drawable/linuxconf"/>
</LinearLayout>
[color=green]方法二[/color]
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
[color=red] android:gravity="center"[/color]
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:id="@+id/spaceshipImage"
android:layout_width="wrap_content"
android:src="@drawable/happy"
android:layout_height="wrap_content" />
</LinearLayout>
[color=green]
方法一[/color]
<?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"
>
<ImageView
android:id="@+id/spaceshipImage"
[color=red]android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="151px"
android:layout_marginBottom="151px"
android:layout_marginLeft="96px"
android:layout_marginRight="96px"[/color]
android:src="@drawable/linuxconf"/>
</LinearLayout>
[color=green]方法二[/color]
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
[color=red] android:gravity="center"[/color]
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:id="@+id/spaceshipImage"
android:layout_width="wrap_content"
android:src="@drawable/happy"
android:layout_height="wrap_content" />
</LinearLayout>