1

Button と ImageView の間に収まる ListView を作成しようとしています。上部に Button があり、下部に ImageView がある RelativeLayout があります。それらの間に ListView が必要です。これが私がやったことです。

ボタンの下に listView が表示されますが、下部の ImageView と重なっています。では、ListView が ImageView の上にあるようにするにはどうすればよいでしょうか。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/control_panel"
        android:layout_width="@dimen/mywidth"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <Button android:id="@+id/button"
            android:layout_height="@dimen/button_size"
            android:layout_width="@dimen/button_size"
            android:scaleType="center"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:background="@drawable/btn_shutter" />

        <ListView android:id="@+id/image_list"
            android:layout_width="@dimen/button_size"
            android:layout_height="wrap_content"
            android:drawSelectorOnTop="false"
            android:layout_above="@+id/image"
            android:layout_below="@+id/button"/>

        <ImageView
           android:id="@+id/image"
           android:layout_width="@dimen/mywidth"
           android:layout_height="@dimen/image_height"
           android:layout_alignParentRight="true"
           android:layout_alignParentBottom="true"/>

</RelativeLayout>
4

2 に答える 2

1

これを試してみてください

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/control_panel"
        android:layout_width="@dimen/mywidth"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <Button android:id="@+id/button"
            android:layout_height="@dimen/button_size"
            android:layout_width="wrap_content"
            android:layout_alignParentTop="true"
            android:background="@drawable/btn_shutter" />

        <ImageView
           android:id="@+id/image"
           android:layout_width="@dimen/mywidth"
           android:layout_height="wrap_content"
           android:layout_alignParentBottom="true"/>

        <ListView android:id="@+id/image_list"
            android:layout_width="@dimen/button_size"
            android:layout_height="fill_parent"
            android:drawSelectorOnTop="false"
            android:layout_above="@+id/image"
            android:layout_below="@+id/button"/>


</RelativeLayout>
于 2012-06-11T17:43:02.480 に答える
0

RelativeLayout に設定されていますか? そうでない場合は、重み付きの LinearLayout を使用できます。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/control_panel"
    android:layout_width="@dimen/mywidth"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <Button android:id="@+id/button"
        android:layout_height="0px"
        android:layout_width="@dimen/button_size"
        android:scaleType="center"
        android:layout_weight="1"
         />

    <ListView android:id="@+id/image_list"
        android:layout_width="@dimen/button_size"
        android:layout_height="0px"
        android:drawSelectorOnTop="false"
        android:layout_weight="6"/>

    <ImageView
       android:id="@+id/image"
       android:layout_width="@dimen/mywidth"
       android:layout_height="0px"
       android:layout_weight="1"/>

于 2012-06-11T17:17:23.143 に答える