0

5 つの textview 要素を持つ Android レイアウトが必要です。レイアウトは次のようになります。

DynamicLargeText1 DynamicLargeText2
DynamicSmallText1 DynamicSmallText2 DynamicSmallText3

すべての textview 要素はコンテンツ テキストを拡大/縮小 (動的) できるため、2 つの要素 (DynamicSmallText2 と DynamicSmallText3) の間に固定スペースがあるため、2 つの要素 (DynamicSmallText2 と DynamicSmallText3) を正しく配置する必要があります。たとえば、DynamicSmallText2 がコンテキスト内で大きくなる場合、テキスト ID は DynamicSmallText3 とその逆にオーバーラップしてはなりません。

一部の人が私を助けてくれることを願っています.thx.

コード内で Smalltext2 と SmallText3 が重複していますか?

<RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="10dp">

<TextView
        android:id="@+id/largeText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="largeText1" />

<TextView
        android:id="@+id/smallText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="smallText1"
        android:layout_below="@id/largeText1"/>


<TextView
        android:id="@+id/largeText2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="largeText2"
        android:layout_alignParentRight="true"/>

<TextView
        android:id="@+id/smallText2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="largeText2"
        android:layout_alignParentRight="true"
        android:layout_below="@id/largeText2"
        android:layout_marginRight="10dp"/>

<TextView
        android:id="@+id/smallText3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="smallText3"
        android:layout_alignParentRight="true"
        android:layout_below="@id/largeText2"
        android:layout_toLeftOf="@id/smallText2"/>

</RelativeLayout>
4

3 に答える 3

0

このような重みの概念を使用します

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="2"
        android:orientation="vertical" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Text 1" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Text 2" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="3"
        android:gravity="bottom|right"
        android:orientation="vertical" 
        >

        <TextView
          android:layout_marginRight="10dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Text 3" />
    </LinearLayout>

    <LinearLayout
        android:gravity="right"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="2"
        android:orientation="vertical" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Text 4" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Text 5" />
    </LinearLayout>

</LinearLayout>

相対レイアウトでコードを変更しました

<TextView
        android:id="@+id/smallText3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/smallText2"
        android:layout_alignBottom="@+id/smallText2"
        android:layout_toLeftOf="@+id/smallText2"
        android:text="smallText3" />
于 2013-10-18T10:52:25.907 に答える