Android의 상대 레이아웃 내에서 부모 텍스트 뷰에 정렬 된 텍스트 뷰를 설정하는 방법은 무엇입니까?

아닐 타쿠 르
<RelativeLayout
    android:id="@+id/rl_top_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/text1"
        style="@style/Typeface.H1.Bold.TextDarkGrey"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="left"
        android:text="500pts"
        android:textColor="@color/text_dark_grey"
        android:textSize="@dimen/tfl_24"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/text2"
        style="@style/Typeface.H1.Bold.TextDarkGrey"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="right"
        android:text="£5.00"
        android:textColor="@color/text_dark_grey"
        android:textSize="@dimen/tfl_24"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/text3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/fdv_text_points"
        android:layout_gravity="center"
        android:gravity="left"
        android:text="@string/points"
        android:textColor="@color/text_mid_grey"
        android:textSize="@dimen/tfl_16" />

    <TextView
        android:id="@+id/text4"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/fdv_text_voucher"
        android:layout_gravity="center"
        android:gravity="right"
        android:text="@string/voucher"
        android:textColor="@color/text_mid_grey"
        android:textSize="@dimen/tfl_16" />
</RelativeLayout>

이것은 내 xml입니다. 왼쪽과 오른쪽에 두 개의 텍스트보기를 설정하고 왼쪽과 오른쪽 아래에 두 개의 텍스트보기를 더 설정했습니다. 아래 텍스트보기는 text1에서 text3에 가운데 정렬되고 text2는 현재 텍스트 4에 정렬 된 text2와 같은 상위 텍스트보기에 정렬되어야합니다. text1 start to text3 및 text2 start of text 4 부모의 정렬 된 중심을 설정하는 방법을 알려주세요.

모하메드 모 하이 딘 AH

@Khemraj 답변은 원하는 출력입니다. 하지만 상대 레이아웃이 필요하면 아래 코드를 시도하십시오.

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/parent"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TextView
        android:id="@+id/tv1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_toLeftOf="@id/divider2"
        android:layout_toStartOf="@+id/divider2"
        android:gravity="center"
        android:text="Title More Text" />

    <TextView
        android:id="@+id/tv2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignEnd="@+id/tv1"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignRight="@+id/tv1"
        android:layout_below="@+id/tv1"
        android:gravity="center"
        android:text="description" />


    <TextView
        android:id="@+id/tv3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_toEndOf="@+id/divider2"
        android:layout_toRightOf="@id/divider2"
        android:gravity="center"
        android:text="Title More Text" />

    <TextView
        android:id="@+id/tv4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@id/tv3"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_alignStart="@+id/tv3"
        android:layout_below="@+id/tv1"
        android:gravity="center"
        android:text="decsription" />

    <View
        android:id="@+id/divider2"
        android:layout_width="1dp"
        android:layout_height="1dp"
        android:layout_centerHorizontal="true"
        android:background="?android:attr/listDivider" />

</RelativeLayout>

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

TOP 리스트

뜨겁다태그

보관