我能夠將我的圖像居中,但不是垂直..任何想法可能會導致這種情況?它應該在屏幕的中心。我也曾嘗試安卓layout_gravity =「center_vertical」但似乎並沒有這樣的伎倆......垂直和水平中心
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/splash"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/splash" />
</LinearLayout>
難道就沒有辦法在一個LinearLayout中居中的圖像? –
沒有內置的好方法,沒有。 LinearLayout的作用類似於HTML--它由上而下構建。垂直方向的佈局重力不起作用,因爲不斷測量該值太昂貴。 – Codeman