我有這樣的作爲佈局如何正確地設置該佈局
<RelativeLayout
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/home_btn"
style="@style/Home_Button">
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textStyle="bold"
android:gravity="center"
android:id="@+id/a"
android:text="@string/centres"/>
<ImageView android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_above="@id/a"
android:src="@drawable/ic_home_btn"/>
</RelativeLayout>
我需要在RelativeLayout的爲中心的TextView的,並且ImageView的是TextView的上面的一部分,具有一組DP偏移(例如,圖片和文字之間的間距爲10dp)
我已嘗試過各種不同的方法和工作到目前爲止。我怎樣才能正確地得到這個工作?
哦,這裏的風格
<style name="Home_Button_NL">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">match_parent</item>
<item name="android:background">@drawable/home_button</item>
<item name="android:textColor">@color/white</item>
<item name="android:gravity">center</item>
<item name="android:layout_marginTop">@dimen/padding_tiny</item>
</style>
我其實已經嘗試過,我認爲它可以工作,但它將兩個元素居中,所以在圖像上方有相同的距離,因爲在文本下面有 –
好的,請檢查我的編輯。 –