片段内的滚动视图根本不滚动 [英] Scrollview inside fragment not scrolling at all
本文介绍了片段内的滚动视图根本不滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在一个带有 tablayout 的活动中使用了三个片段.在片段中,我有 12 个编辑文本,所以我将它们放入滚动视图中.但是滚动不起作用,我只能看到几个编辑文本.
I am using three fragments in one activity with tablayout. In fragment I have 12 edittext so I put them into the scrollview.But scrolling is not working and I can see only few edittexts.
片段.xml
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="1dp"
android:background="#fffbfbfb"
android:fillViewport="false"
android:id="@+id/scrollView">
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="0"
android:background="#fffbfbfb">
........
</scrollview>
activity.xml
activity.xml
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="fill"
app:tabMode="fixed" />
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
推荐答案
好的,我在 fragment.java 文件中做了一件事:
Ok I did one thing in fragment.java file:
scrollView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
scrollView.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});
现在 scrollview 工作正常,但 viewpager 已停止工作我的意思是我无法通过水平触摸更改片段,因为它在将上述方法放入 fragment.java 之前工作
Now scrollview is working fine but viewpager has stopped working I mean I am not able to change fragment by horizontally touch as it was working before putting above method in fragment.java
这篇关于片段内的滚动视图根本不滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文