gpt4 book ai didi

android - 无法单击 SlidingUpPanelLayout 中的子按钮

转载 作者:太空宇宙 更新时间:2023-11-03 10:21:29 25 4
gpt4 key购买 nike

我在项目中使用了 SlidingUpPanelLayout,但遇到了问题。我的 SlidingUpPanelLayout 有 2 个 child 。1) 用于显示数据列表的 ListView - 这是内容2) LinearLayout 和他的 children (textvien, edittext, button) - 这是向上滑动面板

当 SlidingUpPanelLayout 显示时,我尝试点击我的按钮,我的 SlidingUpPanelLayout 立即关闭,我无法点击我的按钮和编辑文本。我怎样才能摆脱这个?我如何在某些 View 上设置点击/显示面板?

谢谢!

<?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>

最佳答案

查看 setDragView 方法,它代表抽屉的“句柄”。另外,检查 View 的 overdraw 情况,可以简化布局,例如:

<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>

渲染相同但 overdraw 少得多

关于android - 无法单击 SlidingUpPanelLayout 中的子按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20131894/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com