0

バックグラウンドをRelativeLayoutに設定しようとしています。問題は、画像のサイズに合わせてレイアウトのサイズが変更されることです。これは望ましくありません。レイアウトのサイズを2つのテキストビューの後にしたいと思います。

とにかく、レイアウトが背景のサイズに拡大縮小されないようにするには?

これはxmlコードです

   <RelativeLayout
    android:id="@+id/hud"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@+drawable/hud_background"
    android:layout_weight="1" >

    <TextView
        android:id="@+id/lblScore"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:text="Score: " />

    <TextView
        android:id="@+id/txtScore"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/lblScore"
        android:layout_alignBottom="@+id/lblScore"
        android:layout_toRightOf="@+id/lblScore"
        android:text="00" />

</RelativeLayout>

よろしく

4

1 に答える 1

1

必要なのは、relativeLayoutのandroid:layout_width = "match_parent"をandroid:layout_width = "wrap_content"に変更することだけだと思います。これにより、サイズはtextViewsのみに準拠するようになります。

なぜandroid:layout_weight = "1"を追加したのですか?レイアウトファイルの一部にすぎませんか?

その場合、それが垂直linearLayoutにある場合は、次を使用します。

android:layout_width="match_parent"
android:layout_height="0px" 

水平方向のlinearLayoutにある場合は、次を使用します。

android:layout_width="wrap_content"
android:layout_height="0px"
于 2013-03-26T21:18:00.500 に答える