Выдвижной ящик не отображается

Я хочу иметь выдвижной ящик, который отображается внизу моего представления, но в настоящее время он не отображается. Я также пытался использовать линейный макет, так как корень с представлением прокрутки имеет вес 1, но это привело к тому, что представление прокрутки и его содержимое не отображались. Любые идеи?

Мой взгляд:

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

<ScrollView
    android:id="@+id/scrollLayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        tools:context=".AddScheduleItemActivity" >

        .
        .
        .

    </LinearLayout>
</ScrollView>

<SlidingDrawer
    android:id="@+id/slidingDrawer1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/scrollLayout"
    android:content="@+id/content"
    android:handle="@+id/handle" >

    <Button
        android:id="@+id/handle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Handle" />

    <LinearLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <Button
            android:id="@+id/hadsfndle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="sdf" />
    </LinearLayout>
</SlidingDrawer>

Thanks, Nathan

Как это должно выглядеть

На картинке я хочу, чтобы синий был прокруткой и содержимым, а зеленый — ручкой для ползунка.

Пробовал следовать некоторым другим предложениям и пришел к этому, который все еще не работает. Содержимое прокрутки отображается нормально, но ползунок не отображается. Нужно еще несколько предложений! Спасибо!

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:gravity="bottom"
android:orientation="vertical" >

<ScrollView
    android:id="@+id/scrollLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

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

        .
        .
        .

    </RelativeLayout>
</ScrollView>

<SlidingDrawer
    android:id="@+id/slidingDrawer1"
    android:layout_width="match_parent"
    android:layout_height="50dip"
    android:layout_alignParentBottom="true"
    android:layout_below="@+id/scrollLayout"
    android:content="@+id/content"
    android:handle="@+id/handle"
    android:orientation="vertical" >

    <Button
        android:id="@+id/handle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Handle" />

    <LinearLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <Button
            android:id="@+id/hadsfndle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="sdf" />
    </LinearLayout>
</SlidingDrawer>

</RelativeLayout>

Что ж, похоже, выдвижной ящик больше не поддерживается, поэтому, думаю, я буду искать альтернативу :(


person Nath5    schedule 05.02.2013    source источник
comment
Не могли бы вы сообщить мне, где именно вы хотите, чтобы ваш слайдер? Внизу экрана или вверху экрана? Я протестировал ваш макет, и его ползунок отображается внизу и открывается снизу вверх.   -  person GrIsHu    schedule 05.02.2013
comment
Я хочу внизу. В макете, который я разместил, вы можете увидеть ползунок, потому что в линейном макете ничего нет. Добавляйте кучу элементов, пока они не превысят пространство на экране. В этот момент вид прокрутки выталкивает ручку ползунка с экрана.   -  person Nath5    schedule 05.02.2013


Ответы (3)


Вы пытаетесь показать свой слайдер внизу, попробуйте следующий код:

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

    <ScrollView
        android:id="@+id/scrollLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <LinearLayout
            android:id="@+id/layout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical" >


        </LinearLayout>
    </ScrollView>

    <LinearLayout
        android:id="@+id/LinearLayout01"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_below="@+id/layout"
        android:orientation="vertical" >

        <SlidingDrawer
            android:id="@+id/SlidingDrawer"
            android:layout_width="wrap_content"
            android:layout_height="250dip"
            android:content="@+id/contentLayout"
            android:handle="@+id/slideHandleButton"
            android:padding="10dip" >

            <Button
                android:id="@+id/slideHandleButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/ic_launcher" >
            </Button>

            <LinearLayout
                android:id="@+id/contentLayout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="#C0C0C0"
                android:gravity="center|top"
                android:orientation="vertical"
                android:padding="10dip" >

                <Button
                    android:id="@+id/Button01"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Content" >
                </Button>

                <Button
                    android:id="@+id/Button02"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Content" >
                </Button>

                <Button
                    android:id="@+id/Button03"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Content" >
                </Button>
            </LinearLayout>
        </SlidingDrawer>
    </LinearLayout>

</RelativeLayout>

Если приведенный выше код не решает вашу проблему, измените родительский макет на LinearLayout, дайте weightsum=10, а затем распределите между вашими scrollview & sliderDrawer равными.

person RobinHood    schedule 05.02.2013

Попробуй это,

Добавьте layout_alignParentBottom к SlidingDrawer.

 android:layout_alignParentBottom="true"
person MuraliGanesan    schedule 05.02.2013

Возможно, на ваш вопрос уже был ответ здесь.

Попробуй это:

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

<ScrollView
    android:id="@+id/scrollLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

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

        .
        .
        .

    </RelativeLayout>
</ScrollView>

<SlidingDrawer
    android:id="@+id/slidingDrawer1"
    android:layout_width="match_parent"
    android:layout_height="50dip"
    android:layout_alignParentBottom="true"
    android:content="@+id/content"
    android:handle="@+id/handle"
    android:orientation="vertical" >

    <Button
        android:id="@+id/handle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Handle" />

    <LinearLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <Button
            android:id="@+id/hadsfndle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="sdf" />
    </LinearLayout>
</SlidingDrawer>

</RelativeLayout>
person r.pedrosa    schedule 07.01.2015