ここRelativeLayoutについての詳細を読むことができます。あなたは両方のTextViews
にmarginLeft
を適用したい場合は、LinearLayout
でそれらの両方を包囲し、その後LinearLayout
300dpのmarginLeft
を与えるか、あなたはここで
300dpコードは両方をラップすることです両方TextViews
marginLeft
で与えることができる可能性がありLinearLayout
でTextViews
:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
//Other stuff here
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="300dp">
<TextView
android:layout_width="200dp"
android:layout_height="200dp"
android:text="use margin left view 1"
android:id="@+id/text"
android:textSize="40sp"
android:background="@color/colorPrimaryDark"/>
<TextView
android:layout_width="290dp"
android:layout_height="200dp"
android:text="not affected by margin view 2 "
android:textSize="40sp"
android:background="@color/colorPrimaryDark"/>
</LinearLayout>
//Other stuff here
</RelativeLayout>
また、ちょうどそのようなalignLeft
と同じ望ましい結果を得るためにRelativeLayout
のプロパティを使用することができます。
試して属性
RelativeLayout
その他
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/text"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_marginLeft="300dp"
android:text="use margin left view 1"
android:textSize="40sp"
android:background="@color/colorPrimaryDark"/>
<TextView
android:layout_width="290dp"
android:layout_height="200dp"
android:layout_alignLeft="@id/text"
android:text="not affected by margin view 2 "
android:textSize="40sp"
android:background="@color/colorPrimaryDark"/>
</RelativeLayout>
がここで見つけることができます:https://developer.android.com/reference/android/widget/RelativeLayout.html
、ここではいくつかが使用されての例です: https://developer.android.com/guide/topics/ui/layout/relative.html