我有以下XML文件來實現一個片段。保證金不起作用
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="@dimen/two_third_width"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_margin="@dimen/extra_margin"
android:background="@drawable/found_item_bg"
tools:context=".FoundItemFragment" >
<TextView
android:id="@+id/found_item_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_margin="@dimen/small_margin"
android:layout_marginRight="@dimen/extra_margin"
android:textColor="@color/BlueText"
android:textSize="@dimen/big_title_font" />
<TextView
android:id="@+id/found_item_catnum_name"
android:layout_width="@dimen/item_bg_width"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/found_item_description"
android:layout_margin="@dimen/small_margin"
android:layout_marginRight="@dimen/big_margin"
android:background="@drawable/item_name_bg"
android:text="@string/catalog_number"
android:textSize="@dimen/found_item_font" />
<TextView
android:id="@+id/found_item_catnum_value"
android:layout_width="@dimen/item_bg_width"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/found_item_catnum_name"
android:layout_alignBaseline="@id/found_item_catnum_name"
android:layout_margin="@dimen/small_margin"
android:background="@drawable/item_value_bg"
android:textSize="@dimen/found_item_font" />
...
</RelativeLayout>
不管我給予的TextView元素的右頁邊距什麼價值,我得到以下渲染:
的第一個問題是,found_item_description文本已消失的地方。主要的問題是,右側的三個TextViews應該放在佈局內部,而不是右側。我已經嘗試了layout_marginRight的各種值,但各種值似乎沒有影響。我認爲有些東西會壓倒或壓制邊際價值,但我不明白它可能是什麼。
如果你想發佈作爲答案,我會檢查它。這是一個不愉快的驚喜,因爲我希望爲其他三方設定默認值,但我想你不能擁有你想要的一切。 –
如你所願,我移動回答:) – Gooziec