我一直無法讓這個LinearLayout移動到它的父親RelativeLayout的垂直中心。我嘗試了很多方法,也許我使用了錯誤的方法,但我不確定。有人可以檢查它,看看我需要添加什麼。謝謝。 LinearLayout右側有一些TextViews,但我沒有包含它們,因爲您不需要它們,但只記得佈局需要位於RelativeLayout的垂直中心,而不是整個中心。ImageView到RelativeLayout的中間 - Android
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/background_card"
android:orientation="horizontal"
android:padding="5dip" >
<!-- ListRow Left sied Thumbnail image -->
<LinearLayout android:id="@+id/thumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="3dip"
android:layout_alignParentLeft="true"
android:gravity="center"
android:background="@drawable/image_bg"
android:layout_marginRight="5dip">
<ImageView
android:id="@+id/list_image"
android:layout_width="50dip"
android:layout_height="50dip"
android:src="@drawable/thumb"/>
</LinearLayout>
我必須使用兩種不同的佈局,因爲每種佈局都有不同的背景xml文件。現在我想知道如果沒有可繪製的xml文件之一,我是否可以做到這一點 – ThePoloDoc
是的,你可以,但基本的想法是保持它們在最開始的時候是相同的,也就是相對的或者是Linear ..,但是就像你剛剛做的那樣你可以使用相對和你可以通過使用'android:layout_alignParentTop =「true」android:layout_centerHorizontal =「true」android:layout_centerVertical =「true」'這些和他們手動拖動它們或給邊緣調整你的用戶界面... – yug