2

画面に2つの相対レイアウトが必要です。上下に。このコードを作成しましたが、機能しません。この場合、両方が挿入された上部の相対レイアウトのみが表示され、wrap_contentを設定しても、このレイアウトはスペース全体を占有します。

編集!:私も失敗する2番目のコードの下に置きます。

編集2!:問題が見つかりました...それは少し...悲しいです。問題は私のテーマにあります。背景を大きすぎるpngファイルに設定しましたが、マニフェストを介してデフォルトのテーマを適用すると、これが発生しました。私がそれを取り除いたとき、それはすべて良いです。

このバージョンも失敗します。

新しいコード:

<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" >

    <RelativeLayout 
        android:id="@+id/some_id" 
        android:layout_above="@+id/some_id2"
        android:layout_alignParentTop="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <Button 
            android:id="@+id/main_button_localize" 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" 
            android:text="@string/main_localize" />

    </RelativeLayout>

    <RelativeLayout 
        android:id="@id/some_id2" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true"  >

        <ToggleButton 
            android:id="@+id/main_help" 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"  />

    </RelativeLayout>

</RelativeLayout>

古いコード:

<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" >

    <RelativeLayout
        android:id="@+id/maps_manager_menu"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true" >

        <!-- Top -->
        <Button 
            android:id="@+id/maps_manager_top_left" 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" 
            android:contentDescription="@string/empty" />

        <Button 
            android:id="@+id/maps_manager_top_middle" 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/maps_manager_top_left"
            android:contentDescription="@string/empty" />

        <Button 
            android:id="@+id/maps_manager_top_right" 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/maps_manager_top_middle"
            android:contentDescription="@string/empty" />

        <!-- Middle -->
        <Button 
            android:id="@+id/maps_manager_middle_left" 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/maps_manager_top_left"
            android:contentDescription="@string/empty" />

        <Button 
            android:id="@+id/maps_manager_middle_middle" 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/maps_manager_middle_left"
            android:layout_below="@id/maps_manager_top_middle"
            android:contentDescription="@string/empty" />

        <Button 
            android:id="@+id/maps_manager_middle_right" 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/maps_manager_middle_middle"
            android:layout_below="@id/maps_manager_top_right"
            android:contentDescription="@string/empty" />

        <!-- Bottom -->
        <Button 
            android:id="@+id/maps_manager_bottom_left" 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/maps_manager_middle_left"
            android:contentDescription="@string/empty" />

        <Button 
            android:id="@+id/maps_manager_bottom_middle" 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/maps_manager_bottom_left"
            android:layout_below="@id/maps_manager_middle_middle"
            android:contentDescription="@string/empty" />

        <Button 
            android:id="@+id/maps_manager_bottom_right" 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/maps_manager_bottom_middle"
            android:layout_below="@id/maps_manager_middle_right"
            android:contentDescription="@string/empty" />

    </RelativeLayout>

    <RelativeLayout
           android:id="@+id/maps_manager_controls"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignBottom="true"
            android:layout_below="@id/maps_manager_menu" >

            <ToggleButton 
                android:id="@+id/maps_manager_help" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

        </RelativeLayout>

</RelativeLayout> 
4

4 に答える 4

1
<ScrollView 
         xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content">

<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" >
             <RelativeLayout
            android:id="@+id/maps_manager_menu"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" 
            android:layout_alignParentTop="true" >

            <!-- Top -->
            <Button 
                android:id="@+id/maps_manager_top_left" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" 
                android:contentDescription="@string/empty" />

            <Button 
                android:id="@+id/maps_manager_top_middle" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@id/maps_manager_top_left"
                android:contentDescription="@string/empty" />

            <Button 
                android:id="@+id/maps_manager_top_right" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@id/maps_manager_top_middle"
                android:contentDescription="@string/empty" />

            <!-- Middle -->
            <Button 
                android:id="@+id/maps_manager_middle_left" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/maps_manager_top_left"
                android:contentDescription="@string/empty" />

            <Button 
                android:id="@+id/maps_manager_middle_middle" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@id/maps_manager_middle_left"
                android:layout_below="@id/maps_manager_top_middle"
                android:contentDescription="@string/empty" />

            <Button 
                android:id="@+id/maps_manager_middle_right" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@id/maps_manager_middle_middle"
                android:layout_below="@id/maps_manager_top_right"
                android:contentDescription="@string/empty" />

            <!-- Bottom -->
            <Button 
                android:id="@+id/maps_manager_bottom_left" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/maps_manager_middle_left"
                android:contentDescription="@string/empty" />

            <Button 
                android:id="@+id/maps_manager_bottom_middle" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@id/maps_manager_bottom_left"
                android:layout_below="@id/maps_manager_middle_middle"
                android:contentDescription="@string/empty" />

            <Button 
                android:id="@+id/maps_manager_bottom_right" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@id/maps_manager_bottom_middle"
                android:layout_below="@id/maps_manager_middle_right"
                android:contentDescription="@string/empty" />

        </RelativeLayout>

        <RelativeLayout
               android:id="@+id/maps_manager_controls"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignBottom="true"
                android:layout_below="@id/maps_manager_menu" >

                <ToggleButton 
                    android:id="@+id/maps_manager_help" 
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />

            </RelativeLayout>
    </RelativeLayout>
 </ScrollView>
于 2012-10-04T12:17:23.117 に答える
1

2 つの子 RelativeLayout の親として垂直方向の LinearLayout を使用することをお勧めします。RelativeLayouts に 80:20 の高さの重みを設定できる場合は、画面全体に収まります。

于 2012-10-04T12:14:06.970 に答える
1
<ScrollView 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" >

 <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
        <RelativeLayout
            android:id="@+id/maps_manager_menu"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" 
            android:layout_alignParentTop="true" >

            <!-- Top -->
            <Button 
                android:id="@+id/maps_manager_top_left" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" 
                android:contentDescription="@string/hello_world" />

            <Button 
                android:id="@+id/maps_manager_top_middle" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@id/maps_manager_top_left"
                android:contentDescription="@string/hello_world" />

            <Button 
                android:id="@+id/maps_manager_top_right" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@id/maps_manager_top_middle"
                android:contentDescription="@string/hello_world" />

            <!-- Middle -->
            <Button 
                android:id="@+id/maps_manager_middle_left" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/maps_manager_top_left"
                android:contentDescription="@string/hello_world" />

            <Button 
                android:id="@+id/maps_manager_middle_middle" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@id/maps_manager_middle_left"
                android:layout_below="@id/maps_manager_top_middle"
                android:contentDescription="@string/hello_world" />

            <Button 
                android:id="@+id/maps_manager_middle_right" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@id/maps_manager_middle_middle"
                android:layout_below="@id/maps_manager_top_right"
                android:contentDescription="@string/hello_world" />

            <!-- Bottom -->
            <Button 
                android:id="@+id/maps_manager_bottom_left" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/maps_manager_middle_left"
                android:contentDescription="@string/hello_world" />

            <Button 
                android:id="@+id/maps_manager_bottom_middle" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@id/maps_manager_bottom_left"
                android:layout_below="@id/maps_manager_middle_middle"
                android:contentDescription="@string/hello_world" />

            <Button 
                android:id="@+id/maps_manager_bottom_right" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@id/maps_manager_bottom_middle"
                android:layout_below="@id/maps_manager_middle_right"
                android:contentDescription="@string/hello_world" />

        </RelativeLayout>

        <RelativeLayout
               android:id="@+id/maps_manager_controls"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/maps_manager_menu" >

                <ToggleButton 
                    android:id="@+id/maps_manager_help" 
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />

            </RelativeLayout>
    </RelativeLayout>
</ScrollView>
于 2012-10-04T12:35:27.720 に答える
0


次の手順に従います。

  1. 最上位の相対レイアウトにIDを追加します。たとえば、android:id = "@ + id / rtvlt_first"
  2. 2番目のRelativeLayoutで、alignparenttopプロパティを削除します。
  3. android:tobottomof = "@ id / rtvlt_first"を追加...

    これを試してください....
    幸運を祈ります!
于 2012-10-04T12:05:49.270 に答える