1

TextViews2 つの異なる に配置されたトウのベースラインを揃えたいRelativeLayouts。以下は私が使用しているコードです:

        <RelativeLayout 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="right">

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

        </RelativeLayout>

         <RelativeLayout 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">

             <TextView 
                 android:id="@+id/tv_city_b"
                 android:layout_width="fill_parent"
                 android:layout_height="wrap_content"
                 android:layout_alignBottom="@id/tv_city"
                 android:background="@drawable/txt_field_white"/>

        </RelativeLayout>

tv_city_aのベースラインを合わせたいのですtv_city_bが、上記のコードが機能しません。

注:設計要件により、 をTextView2 つの異なるに配置する必要がありRelativeLayoutます。私はそれらを1つに入れることはできません。

編集以下は私が得ている出力です: ここに画像の説明を入力

4

1 に答える 1

0

親が異なるビューのベースラインをリンクすることはできません。唯一のオプションは、それらを1つに結合するRelativeLayoutか、正しいパディング、マージン、親の配置などを指定して整列させることです。

android:paddingTop="5dp"編集: 2番目のRelativeLayoutにあるため、間違った出力が来ています

于 2013-05-21T08:56:17.530 に答える