하나의 TextView와 하나의 ImageView로 구성된 간단한 LinearLayout을 가지고 있습니다. TextView의 텍스트가 오른쪽으로 정렬되기를 원하지만 결과는 텍스트가 왼쪽으로 정렬되었음을 나타냅니다. 레이아웃 XML에 문제가 있습니까? 감사.android : layout_gravity가 예상대로 작동하지 않습니다.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:background="#E8E3E4">
<LinearLayout android:orientation="horizontal"
android:layout_width="wrap_content" android:layout_height="wrap_content"
>
<TextView android:layout_width="260dp" android:layout_height="wrap_content"
android:text="More Comments" android:textStyle="bold" android:background="#ff0000"
android:textColor="#121222" android:layout_gravity="right" />
<ImageView android:layout_width="50dp"
android:layout_height="wrap_content" android:src="@drawable/arrow_right"
android:layout_gravity="center" android:scaleType="centerInside" />
</LinearLayout>
</LinearLayout>
감사합니다, 마이클. 그러나 언급 한 해결 방법은 작동하지 않습니다.
나는 RelativeLayout의를 사용하려고하지만 여전히 날 같은 결과를 주었다 더 댓글 (아이콘) 내가 기대했던
이
는 RelativeLayout의의 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="fill_parent">
<TextView android:id="@+id/label" android:layout_width="260dp"
android:layout_height="wrap_content" android:text="More Comments"
android:textStyle="bold" android:background="#ff0000"
android:textColor="#121222" android:layout_gravity="right" />
<ImageView android:layout_width="50dp" android:layout_height="wrap_content"
android:src="@drawable/arrow_right" android:layout_gravity="center"
android:scaleType="centerInside" android:layout_toRightOf="@id/label" />
</RelativeLayout>
, 나는 아래의 XML이있다. 나는 출력이 될 것으로 예상 :
RightLeft
그러나 실제 출력은 다음과 같습니다
Right Left
그래서 해결 방법은 나를 위해 작동하지 않습니다. 이견있는 사람?
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="1.0"
android:text="RIGHT"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:text="LEFT"/>
</LinearLayout>
xml을 포함 할 수 있습니까? – jball
그는 그렇게했고, 단지 형식을 지정하지 않았습니다. –
(또한 : 수정되었으므로 코드가 *로 표시됩니다.) –