首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在NestedScrollView中使用NestedScrollView时不能正常工作

在NestedScrollView中使用NestedScrollView时不能正常工作
EN

Stack Overflow用户
提问于 2018-05-21 08:10:20
回答 1查看 94关注 0票数 0

在Android中,图像视图应该在滚动启动之前显示,但效果相反。当我在屏幕上按住手指时,如果我在Imageview被禁用之前上下滚动,滚动视图开始向下滚动,然后Imageview开始关闭。这是我的密码。

代码语言:javascript
复制
<android.support.v4.widget.NestedScrollView
        android:id="@+id/nestedScroll"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"
        android:fillViewport="true"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">
       <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/user_menu_bg"
            android:orientation="vertical">

            <ListView
                android:id="@+id/menu_list"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:divider="@drawable/menu_list_divider"
                android:listSelector="@android:color/transparent"
                android:nestedScrollingEnabled="true" />
        </LinearLayout>

    </android.support.v4.widget.NestedScrollView>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-05-21 08:15:51

最好使用NonScrollableListView而不是listview。或者使用RecyclerView.

试一试

代码语言:javascript
复制
public class NonScrollListView extends ListView {

    public NonScrollListView(Context context) {
        super(context);
    }
    public NonScrollListView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    public NonScrollListView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }
    @Override
    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            int heightMeasureSpec_custom = MeasureSpec.makeMeasureSpec(
                    Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
            super.onMeasure(widthMeasureSpec, heightMeasureSpec_custom);
            ViewGroup.LayoutParams params = getLayoutParams();
            params.height = getMeasuredHeight();    
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50444534

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档