简体   繁体   English

滑动抽屉下的内容-Android

[英]Content Under Sliding Drawer - Android

I'm having trouble getting this button to only appear under the drawer. 我无法让此按钮仅出现在抽屉下面。 I'm using a package that I found online and not the sliding drawer that comes with the SDK. 我使用的是我在网上找到的软件包,而不是SDK随附的滑动抽屉。

Here is the main.xml layout: 这是main.xml布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" xmlns:ns="http://schemas.android.com/apk/res/it.sephiroth.demo.slider"> 

    <Button
        android:id="@+id/button_open"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:text="@string/open"
        android:layout_centerInParent="true"
        android:visibility="gone" />


    <it.sephiroth.demo.slider.widget.MultiDirectionSlidingDrawer
        xmlns:my="http://schemas.android.com/apk/res/it.sephiroth.demo.slider"
        android:id="@+id/drawer"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        ns:content="@+id/content"
        ns:direction="topToBottom"
        ns:handle="@+id/handle" >

        <include
            android:id="@id/content"
            layout="@layout/pen_content" />

        <ImageView
            android:id="@id/handle"
            android:layout_width="wrap_content"
            android:layout_height="40dp"
            android:src="@drawable/sliding_drawer_handle_bottom" />
    </it.sephiroth.demo.slider.widget.MultiDirectionSlidingDrawer>

    <LinearLayout
        android:id="@+id/frameLayout1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="120dp"
        android:layout_marginTop="133dp" >

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

</RelativeLayout>

And in case it will help, here is the pen_content.xml layout that is included: 如果有帮助的话,下面是其中包含的pen_content.xml布局:

    <RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="bottom"
    android:background="@drawable/pattern1"
    >

    <LinearLayout
        android:layout_alignParentBottom="true" 
        android:layout_width="fill_parent"
        android:orientation="vertical"
        android:gravity="bottom"
        android:layout_height="wrap_content">
        <LinearLayout
            android:layout_marginBottom="5dp"
            android:layout_marginTop="5dp"
            android:padding="5dp"
            android:orientation="horizontal"
            android:gravity="center_vertical"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <TextView
                android:text="@string/option1"
                android:id="@+id/textView1"
                android:minWidth="100dp"
                android:textColor="@android:color/black"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"></TextView>
            <SeekBar
                android:layout_width="fill_parent"
                android:id="@+id/bar_size"
                android:layout_height="wrap_content"></SeekBar>
        </LinearLayout>
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="1px"
            android:background="#FF999999" />
        <LinearLayout
            android:layout_marginBottom="5dp"
            android:layout_marginTop="5dp"
            android:padding="5dp"
            android:orientation="horizontal"
            android:gravity="center_vertical"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <TextView
                android:text="@string/option2"
                android:id="@+id/textView2"
                android:minWidth="100dp"
                android:textColor="@android:color/black"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"></TextView>
            <SeekBar
                android:layout_width="fill_parent"
                android:id="@+id/bar_alpha"
                android:layout_height="wrap_content"></SeekBar>
        </LinearLayout>
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="1px"
            android:background="#FF999999" />
        <LinearLayout
            android:layout_marginBottom="5dp"
            android:layout_marginTop="5dp"
            android:padding="5dp"
            android:orientation="horizontal"
            android:gravity="center_vertical"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <TextView
                android:text="@string/option3"
                android:id="@+id/textView3"
                android:minWidth="100dp"
                android:textColor="@android:color/black"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"></TextView>
            <SeekBar
                android:layout_width="fill_parent"
                android:id="@+id/bar_blur"
                android:layout_height="wrap_content"></SeekBar>
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="1px"
            android:background="#FF999999" />
        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <LinearLayout
                android:id="@+id/layout01"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:background="#FFEEEEEE"
                android:padding="10dp">
                <Button
                    android:id="@+id/button_close"
                    android:text="@string/close"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:minWidth="100dp"></Button>
            </LinearLayout>
            <LinearLayout
                android:layout_above="@id/layout01"
                android:layout_width="fill_parent"
                android:layout_height="1px"
                android:background="#FF999999" />
        </RelativeLayout>

    </LinearLayout>

</RelativeLayout>

Here are screenshots of how it acts now (the first is when the slider is open, the second is closed). 这是它现在的行为的屏幕截图(第一个是打开滑块时,第二个是关闭时)。 You can see how the button remains visible when the slider is open. 您可以看到打开滑块时按钮如何保持可见。 I want it to only be visible on the layout behind the drawer. 我希望它仅在抽屉后面的布局中可见。 Thanks! 谢谢!

开放状态

封闭状态

See My answer here and it will Surly help you a lot. 在这里查看我的答案,它将对Surly有所帮助。 . . .

Updated 更新

It seems that you are using the example that i have given in the link. 看来您正在使用我在链接中给出的示例。 Anyways you just have to set the transperancy of the slidingDrawer layout. 无论如何,您只需要设置slideDrawer布局的透明度即可。 Just see the code proper and set the transperancy and it will solve your issue. 只需查看正确的代码并设置透明性,它就能解决您的问题。

Enjoy Coading. 享受Coading。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM