Android ScrollView不在片段中滚动
我在谷歌上搜索了我的问题,并在stackoverflow上阅读了类似的问题,但我没有解决任何问题 我有一个带有coordinatorLayout(main.xml)的布局和一个带有relativeLayout(fragment.xml)的片段 main.xmlAndroid ScrollView不在片段中滚动,android,android-layout,android-fragments,scrollview,Android,Android Layout,Android Fragments,Scrollview,我在谷歌上搜索了我的问题,并在stackoverflow上阅读了类似的问题,但我没有解决任何问题 我有一个带有coordinatorLayout(main.xml)的布局和一个带有relativeLayout(fragment.xml)的片段 main.xml fragment.xml 正如您所看到的,我在scrollView中有更多按钮,但没有滚动。查看页面中的ui元素,我最初认为是因为查看页面,但我已经测试了它test_fragment.xml,它工作得非常好 滚动视图当我按住
fragment.xml
正如您所看到的,我在scrollView中有更多按钮,但没有滚动。查看页面中的ui元素,我最初认为是因为查看页面,但我已经测试了它test_fragment.xml,它工作得非常好
滚动视图当我按住看不见的寻呼机时滚动(例如,我的第一个选项卡)
并将手指向上/向下移动
test_fragment.xml
有什么问题
提前感谢。由于您使用的是
AppBarLayout
,因此无法使用simpleScrollView
。您应该改用NestedScrollview
。您已经将您的滚动视图
放在相对视图内,这是不必要的。使用NestedScrollView
删除该RelativeLayout
,然后重试
我想这会有帮助的 由于您使用的是AppBarLayout
,因此无法使用简单的ScrollView
。您应该改用NestedScrollview
。您已经将您的滚动视图
放在相对视图内,这是不必要的。使用NestedScrollView
删除该RelativeLayout
,然后重试
我想这会有帮助的 很高兴听到……)帮助我解决了这个问题,很难找到这个问题(带有scrollview的AppBarLayout),你是如何识别这个问题的:)?@Amritesh我很高兴它能帮上忙。关于这个问题,android开发网站有所有答案,如果我们知道可以找到;)很高兴听到……)帮助我解决了这个问题,很难找到这个问题(带有scrollview的AppBarLayout),你是如何识别这个问题的:)?@Amritesh我很高兴它能帮上忙。关于这个问题,android开发网站有所有答案,如果我们知道可以找到;)
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:paddingRight="16dp"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:layout_width="match_parent"
android:layout_height="40dp"
android:text="FRAGMENT TITLE"
android:textSize="20sp"
android:textColor="@color/colorWhite"
android:id="@+id/main_toolbar_title"
android:gravity="center_vertical" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:background="@color/colorWhite"
android:layout_width="match_parent"
android:layout_height="60dp" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:background="#f3f3f3">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:contentPadding="1dp"
card_view:cardCornerRadius="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:layout_width="match_parent"
android:layout_height="66dp"
android:textAllCaps="false"
android:text="Button Title"
android:textSize="18sp"
android:textColor="#404040"/>
<Button
android:layout_width="match_parent"
android:layout_height="66dp"
android:textAllCaps="false"
android:text="Button Title"
android:textSize="18sp"
android:textColor="#404040"/>
<Button
android:layout_width="match_parent"
android:layout_height="66dp"
android:textAllCaps="false"
android:text="Button Title"
android:textSize="18sp"
android:textColor="#404040"/>
<Button
android:layout_width="match_parent"
android:layout_height="66dp"
android:textAllCaps="false"
android:text="Button Title"
android:textSize="18sp"
android:textColor="#404040"/>
<Button
android:layout_width="match_parent"
android:layout_height="66dp"
android:textAllCaps="false"
android:text="Button Title"
android:textSize="18sp"
android:textColor="#404040"/>
<Button
android:layout_width="match_parent"
android:layout_height="66dp"
android:textAllCaps="false"
android:text="Button Title"
android:textSize="18sp"
android:textColor="#404040"/>
<Button
android:layout_width="match_parent"
android:layout_height="66dp"
android:textAllCaps="false"
android:text="Button Title"
android:textSize="18sp"
android:textColor="#404040"/>
<Button
android:layout_width="match_parent"
android:layout_height="66dp"
android:textAllCaps="false"
android:text="Button Title"
android:textSize="18sp"
android:textColor="#404040"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>
</RelativeLayout>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/quickreturn_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />