목록보기 항목의 네 구석에 4 개의 물체를 놓으려고합니다. 상대 레이아웃을 사용하고 있습니다. 어떤 이유로 개체가 왼쪽에만 정렬됩니다. 2 개의 물체가 오른쪽에 있어야합니다. layout_gravity도 사용하고 있지만 사용하지는 않습니다. 그들은 모두 왼쪽에 정렬됩니다. 내가 교체하는 경우 :안드로이드 RelativeLayout 모서리에 물체 넣기
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/distancebackground"
android:layout_alignParentTop="true" />
<TextView
android:id="@+id/distanceWindow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
이 include_time_window
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:src="@drawable/distancebackground" />
<TextView
android:id="@+id/timeWindow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="123"/>
편집을 포함 include_distance_window.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<include
android:id="@+id/fromDistanceWindowLayout"
android:layout_alignParentLeft="true"
android:layout_gravity="left"
layout="@layout/include_distance_window" />
<include
android:id="@+id/toDistanceWindowLayout"
android:layout_alignParentRight="true"
android:layout_gravity="right"
layout="@layout/include_distance_window" />
<include
android:id="@+id/fromTimeWindowLayout"
android:layout_alignParentLeft="true"
layout="@layout/include_time_window" />
<include
android:id="@+id/toTimeWindowLayout"
android:layout_alignParentRight="true"
layout="@layout/include_time_window" />
은 다음과 같습니다 두 번째는 포함 된 XML의 내용을 모두 포함하여 잘 작동합니다.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/distancebackground"
android:layout_alignParentTop="true" />
<TextView
android:id="@+id/distanceWindow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
왜 그런지 궁금합니다.
스마트 변경. 그렇습니다, 그것은 차이를 만들어 냈습니다. 아이들은 구석에서 시작했습니다. 그리고 예, 중력은 아무런 차이를 만들지 않았습니다. – Siddharth
나는 이제 막 비슷한 것을 마쳤다. 기꺼이 도와주세요 : D. 타이밍과 상황. –