-1

やあ、

画面サイズに依存しないレイアウトを設計しようとしています。実際に、画面の中央に大きなサイズの追加があるサンプル レイアウトを設計しています。上部残域と下部残部の中央にテキストがあります。xml は次のとおりです。

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

    <ImageView
        android:id="@+id/ads_layout_large"
        android:layout_width="300dp"
        android:layout_height="250dp"
        android:layout_centerInParent="true"
        android:background="@android:color/background_light" />

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@id/ads_layout_large"
        android:background="#fff000"
        android:gravity="center"
        android:text="@string/exit_enjoyed_text" />

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@id/ads_layout_large"
        android:background="#fff000"
        android:gravity="center"
        android:text="@string/exit_enjoyed_text" />
</RelativeLayout>

問題は、上部で作業していて、テキストが残りの領域のちょうど中央にあるのに、下部TextViewが画面の半分を覆っていることです。間違いを見つけるのを手伝ってもらえますか? または、同じものを設計する他の方法はありますか?

4

1 に答える 1

1

ここにあなたの問題があると思います:

android:layout_height="fill_parent"

TextView の高さを fill_parent に設定すると、テキストビューが拡張されて親のサイズに達します。代わりに、wrap_content または "30dp" などの静的な値を使用してください。

于 2013-02-25T08:14:52.523 に答える