Android的SlidingDrawer不会禁用“下的”抽屉按钮抽屉、按钮、Android、SlidingDrawer

由网友(为自己拼个未来)分享简介:这是该方案:我有一个按钮B,和slidingdrawer,当拉出覆盖了整个屏幕。当我拔出屏幕,触摸其中B曾经是可见的屏幕,仍然执行其行动。 我怎样才能解决这个? 我发现this螺纹描述同样的问题,但没有答案被接受和那些给予我没能获得工作。 更新:我有一个名为Report.java文件,相应地report.xml文件...

这是该方案: 我有一个按钮B,和slidingdrawer,当拉出覆盖了整个屏幕。 当我拔出屏幕,触摸其中B曾经是可见的屏幕,仍然执行其行动。

我怎样才能解决这个?

我发现this螺纹描述同样的问题,但没有答案被接受和那些给予我没能获得工作。

更新:我有一个名为Report.java文件,相应地report.xml文件,如下图所示。

 < SlidingDrawer
     机器人:ID =@ + ID /抽屉
     机器人:layout_width =FILL_PARENT
     机器人:layout_height =WRAP_CONTENT
     机器人:手柄=@ + ID / reportSlideButton
     机器人:CONTENT =@ + ID / reportContent
     机器人:方向=横向>

    <的LinearLayout
        机器人:ID =@ ID / reportContent
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =FILL_PARENT
        机器人:方向=垂直
        机器人:layout_weight =1
        机器人:填充=10dp
        机器人:背景=@色/ bg_c​​olor>
            < TextView的机器人:ID =@ + ID / garbageTypeTextView
                机器人:layout_height =WRAP_CONTENT
                机器人:文字颜色=@色/文本
                机器人:layout_width =FILL_PARENT
                机器人:文本=@字符串/ garbageTypeString
                机器人:TEXTSTYLE =黑体/>
            <微调机器人:ID =@ + ID / garbageTypeSpinner
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_width =FILL_PARENT/>
            < TextView的机器人:ID =@ + ID / textViewForDateTitle
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:文本=@字符串/ dateString
                机器人:文字颜色=@色/文本
                机器人:TEXTSTYLE =黑体/>
            < TextView的机器人:ID =@ + ID / dateTextView
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:文字颜色=@色/文本/>
            < TextView的机器人:ID =@ + ID / textViewForAddressTitle
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_width =WRAP_CONTENT
                机器人:文本=@字符串/ addressString
                机器人:文字颜色=@色/文本
                机器人:TEXTSTYLE =黑体/>
            < TextView的机器人:ID =@ + ID / addressTextView
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:文字颜色=@色/文本/>
            < TextView的机器人:ID =@ + ID / textViewForPositionTitle
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_width =WRAP_CONTENT
                机器人:文本=@字符串/ positionString
                机器人:文字颜色=@色/文本
                机器人:TEXTSTYLE =黑体/>
            < TextView的机器人:ID =@ + ID / positionTextView
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:文字颜色=@色/文本/>
            < TextView的机器人:ID =@ + ID / textViewForCommentTitle
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_width =WRAP_CONTENT
                机器人:文本=@字符串/ commentString
                机器人:文字颜色=@色/文本
                机器人:TEXTSTYLE =黑体/>
            < EditText上机器人:ID =@ + ID / commentTextBox
                机器人:layout_height =FILL_PARENT
                机器人:layout_width =FILL_PARENT
                机器人:layout_weight =1/>
            <按钮机器人:ID =@ + ID / sendCrapportButton
                机器人:的onClick =sendCrapport
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_width =FILL_PARENT
                机器人:文本=Skicka融洽/>

    < / LinearLayout中>
        <按钮机器人:ID =@ ID / reportSlideButton
            机器人:layout_width =40dp
            机器人:layout_height =40dp
            机器人:文本=>中/>
< / SlidingDrawer>
 

添加组件:

 保护无效addComponents(){
    takePictureButton =(的ImageButton)findViewById(R.id.takePictureButton);
    slidingDrawer =(SlidingDrawer)findViewById(R.id.drawer);
}
 
Android SlidingDrawer 抽屉效果

解决方案

您可以添加机器人:可点击=true将您的滑块内容标记(ID reportContent)。这样,它不会点击通过。滑块在你的按钮应该仍然工作。我希望;)

This is the scenario: I have a button B, and a slidingdrawer that when pulled out covers the entire screen. When I pull out the screen, and touch the screen where B used to be visible, its action is still executed.

How can I get around this?

I found this thread describing the very same problem, but no answer was accepted and the ones given I didn't manage to get working.

UPDATE: I have a file named Report.java, with a corresponding report.xml file as seen below.

    <SlidingDrawer
     android:id="@+id/drawer"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:handle="@+id/reportSlideButton"
     android:content="@+id/reportContent"
     android:orientation="horizontal">

    <LinearLayout 
        android:id="@id/reportContent" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
        android:orientation="vertical" 
        android:layout_weight="1"
        android:padding="10dp"
        android:background="@color/bg_color">
            <TextView android:id="@+id/garbageTypeTextView" 
                android:layout_height="wrap_content" 
                android:textColor="@color/text" 
                android:layout_width="fill_parent" 
                android:text="@string/garbageTypeString" 
                android:textStyle="bold"/>
            <Spinner android:id="@+id/garbageTypeSpinner"
                android:layout_height="wrap_content" 
                android:layout_width="fill_parent"/>
            <TextView android:id="@+id/textViewForDateTitle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" 
                android:text="@string/dateString"
                android:textColor="@color/text" 
                android:textStyle="bold" />
            <TextView android:id="@+id/dateTextView"
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:textColor="@color/text" />
            <TextView android:id="@+id/textViewForAddressTitle"
                android:layout_height="wrap_content" 
                android:layout_width="wrap_content" 
                android:text="@string/addressString"
                android:textColor="@color/text" 
                android:textStyle="bold" />
            <TextView android:id="@+id/addressTextView"
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:textColor="@color/text" />
            <TextView  android:id="@+id/textViewForPositionTitle"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content" 
                android:text="@string/positionString"
                android:textColor="@color/text" 
                android:textStyle="bold" />
            <TextView android:id="@+id/positionTextView"
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:textColor="@color/text" />
            <TextView android:id="@+id/textViewForCommentTitle"
                android:layout_height="wrap_content" 
                android:layout_width="wrap_content" 
                android:text="@string/commentString"
                android:textColor="@color/text" 
                android:textStyle="bold" />
            <EditText android:id="@+id/commentTextBox"
                android:layout_height="fill_parent"
                android:layout_width="fill_parent" 
                android:layout_weight="1"/>
            <Button android:id="@+id/sendCrapportButton" 
                android:onClick="sendCrapport"
                android:layout_height="wrap_content" 
                android:layout_width="fill_parent"
                android:text="Skicka rapport" />

    </LinearLayout>
        <Button android:id="@id/reportSlideButton"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:text=">"/>
</SlidingDrawer>

Adding components:

protected void addComponents() {
    takePictureButton = (ImageButton) findViewById(R.id.takePictureButton);
    slidingDrawer = (SlidingDrawer) findViewById(R.id.drawer);
}

解决方案

you could add android:clickable="true" to your slider content tag (id reportContent). that way it won't "click through". your buttons inside the slider should still work.. i hope ;)

阅读全文

相关推荐

最新文章