Can't click children button in SlidingUpPanelLayout

可紊 提交于 2019-12-10 16:55:58

问题


I use SlidingUpPanelLayout in my project and i have a problem with it. My SlidingUpPanelLayout has 2 children. 1) ListView for showing list of data - this is content 2) LinearLayout with his children (textvien, edittext, button) - this is slide up panel

When SlidingUpPanelLayout is showing i try to click on my button, and my SlidingUpPanelLayout immediately close, and i can't click on my button and edittext. How can i get rid of this? how can i setup click/show up panel on some View?

thanks!

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"> 
    <com.sothree.slidinguppanel.SlidingUpPanelLayout
        android:id="@+id/sliding_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >          
        <ListView               
            android:paddingLeft="10dp"
            android:paddingRight="10dp"
            android:divider="@drawable/shape_divider_comments"
            android:dividerHeight="1dp"
            android:id="@+id/lvReviews"
            android:visibility="gone"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >
        </ListView>
        <LinearLayout
            android:id="@+id/rlSlidingContent"
            android:gravity="center|top"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >              
            <ScrollView
                android:visibility="visible"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >
                    <LinearLayout 
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:orientation="vertical">                     
                        <EditText
                            style="@style/StyleEditText"
                            android:id="@+id/etPersonName"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:ems="10"
                            android:hint="@string/your_name_hint"
                            android:inputType="textPersonName" >

                        </EditText>                                                 
                        <Button
                            style="@style/StyleButton"
                            android:visibility="visible"
                            android:id="@+id/btnAddComment"
                            android:layout_gravity="center"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Add" />
                    </LinearLayout>
                </ScrollView>
        </LinearLayout>
    </com.sothree.slidinguppanel.SlidingUpPanelLayout>
</RelativeLayout>

回答1:


Check out the method setDragView it represents the "handle" of the drawer. Also, check the overdraw of your views, you could simplify your layout, for example:

<com.sothree.slidinguppanel.SlidingUpPanelLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ListView
    android:id="@+id/lvReviews"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:divider="@drawable/shape_divider_comments"
    android:dividerHeight="1dp"
    android:paddingLeft="10dp"
    android:paddingRight="10dp"
    android:visibility="gone" />

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    android:visibility="visible">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <EditText
            android:id="@+id/etPersonName"
            style="@style/StyleEditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10"
            android:hint="@string/your_name_hint"
            android:inputType="textPersonName">

        </EditText>

        <Button
            android:id="@+id/btnAddComment"
            style="@style/StyleButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="Add"
            android:visibility="visible" />
    </LinearLayout>
</ScrollView>

</com.sothree.slidinguppanel.SlidingUpPanelLayout>

renders the same with far less overdraw



来源:https://stackoverflow.com/questions/20131894/cant-click-children-button-in-slidinguppanellayout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!