Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Android NestedScrollView的子视图忽略第一次单击大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我在我的片段中使用协调器布局和nestedScrollView来进行折叠工具栏动画.我正在动态地向我的嵌套Scrollview容器添加视图.我已经在nestedScrollView中的视图上实现了onClickListener,但是始终忽略对任何视图的第一次单击.当我再次点击或超过它的工作时.我的 XML代码如下:

<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android open source Project
~
~ Licensed under the Apache License,Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~      http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in wriTing,software
~ diStributed under the License is diStributed on an "AS IS" BASIS,~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<android.support.design.widget.CoordinatorLayout
    android:id="@+id/main_content"
    xmlns:android="http://scheR_50_11845@as.android.com/apk/res/android"
    xmlns:app="http://scheR_50_11845@as.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:collapsedtitleTextAppearance="@style/toolBartitleStyle"
        app:contentScrim="@color/priMary"
        app:expandedtitleMarginBottom="@dimen/dimen_21dp"
        app:expandedtitleMarginStart="@dimen/dimen_13dp"
        app:expandedtitleTextAppearance="@style/ExpandedToolBarTextTheme"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <ImageView
            android:id="@+id/BACkdrop"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true"
            android:scaleType="centerCrop"
            android:src="@drawable/locality_bg"
            app:layout_collapseMode="parallax"
            app:layout_collapseParallaxMultiplier="0.2"/>

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_collapseMode="pin"/>

    </android.support.design.widget.CollapsingToolbarLayout>

</android.support.design.widget.AppBarLayout>

<android.support.v4.widget.nestedScrollView
    android:id="@+id/scroll_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layouT_Behavior="@String/appbar_scrolling_view_behavior">

    <LinearLayout
        android:id="@+id/base_view_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:BACkground="@color/black_20pc"
        android:orientation="vertical">

    </LinearLayout>

</android.support.v4.widget.nestedScrollView>

<com.locon.housing.views.RobotoMediumButton
    android:id="@+id/view_lisTings"
    android:layout_width="match_parent"
    android:layout_height="@dimen/dimen_56dp"
    android:layout_gravity="bottom"
    android:BACkground="@color/vida_loca"
    android:gravity="center"
    android:text="@String/alerts_view_lisTings"
    android:textColor="@color/white"
    android:textSize="@dimen/fontsize_medium"/>

<android.support.design.widget.FloaTingActionButton
    android:id="@+id/fab_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="@dimen/dimen_16dp"
    android:clickable="true"
    android:src="@drawable/ic_action_new"/>

</android.support.design.widget.CoordinatorLayout>

似乎nestedScrollView正在拦截触摸事件,而不是第一次传递给孩子.
我该如何解决这个问题?

解决方法

大佬总结

以上是大佬教程为你收集整理的Android NestedScrollView的子视图忽略第一次单击全部内容,希望文章能够帮你解决Android NestedScrollView的子视图忽略第一次单击所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。