android – 在使用TabLayout和ViewPager的Fragment中启用滚动

android – 在使用TabLayout和ViewPager的Fragment中启用滚动,第1张

概述你好! 我希望这个视图可以滚动: 如您所见,TAB1中的“TEMP CONTENT”就是模拟可能出现的临时内容. 我现在要做的是使整个页面可滚动.我设法做的是制作TAB1的内容,因此,TabLayout的内容可滚动,但这不是我想要做的.如上所述,整个页面应该是. 这是持有视图的布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout 你好!
我希望这个视图可以滚动:

如您所见,TAB1中的“TEMP CONTENT”就是模拟可能出现的临时内容.

我现在要做的是使整个页面可滚动.我设法做的是制作TAB1的内容,因此,TabLayout的内容可滚动,但这不是我想要做的.如上所述,整个页面应该是.

这是持有视图的布局:

<?xml version="1.0" enCoding="utf-8"?>    <linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"        xmlns:app="http://schemas.androID.com/apk/res-auto"        xmlns:tools="http://schemas.androID.com/tools"        androID:layout_wIDth="match_parent"        androID:layout_height="match_parent"        androID:orIEntation="vertical"        app:layout_behavior="@string/appbar_scrolling_vIEw_behavior"        tools:context="at.codecrane.whosnext.MainActivity">        <relativeLayout            androID:layout_wIDth="match_parent"            androID:layout_height="200dp">            <ImageVIEw                androID:ID="@+ID/imageVIEw2"                androID:layout_wIDth="match_parent"                androID:layout_height="match_parent"                app:srcCompat="@androID:color/darker_gray" />            <ImageVIEw                androID:ID="@+ID/imageVIEw3"                androID:layout_wIDth="100dp"                androID:layout_height="100dp"                app:srcCompat="@drawable/ic_face"                androID:layout_alignParenttop="true"                androID:layout_centerHorizontal="true"                androID:layout_margintop="32dp" />            <TextVIEw                androID:ID="@+ID/textVIEw2"                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:layout_below="@+ID/imageVIEw3"                androID:layout_centerHorizontal="true"                androID:text="Temp name"                androID:textSize="18sp" />        </relativeLayout>        <androID.support.v4.vIEw.VIEwPager            androID:ID="@+ID/vIEwpager"            androID:layout_wIDth="match_parent"            androID:layout_height="match_parent">            <androID.support.design.Widget.TabLayout                androID:ID="@+ID/tab_layout"                androID:layout_wIDth="match_parent"                androID:layout_height="wrap_content"                app:tabIndicatorcolor="@color/colorPrimary">                <androID.support.design.Widget.TabItem                    androID:layout_wIDth="match_parent"                    androID:layout_height="match_parent"                    androID:text="General" />                <androID.support.design.Widget.TabItem                    androID:layout_wIDth="match_parent"                    androID:layout_height="match_parent"                    androID:text="Statistics" />            </androID.support.design.Widget.TabLayout>        </androID.support.v4.vIEw.VIEwPager>    </linearLayout>

这是VIEwPager-Content的片段布局:

<!-- Todo: Update blank fragment layout --><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"    xmlns:tools="http://schemas.androID.com/tools"    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:orIEntation="vertical">    <TextVIEw        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:text="TEMP CONTET"        androID:textSize="20dp" />    <TextVIEw        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:text="TEMP CONTET"        androID:textSize="20dp" />    <TextVIEw        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:text="TEMP CONTET"        androID:textSize="20dp" />    <TextVIEw        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:text="TEMP CONTET"        androID:textSize="20dp" />    <TextVIEw        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:text="TEMP CONTET"        androID:textSize="20dp" /></linearLayout>

提前致谢!

解决方法 一起使用ScrollvIEw和nestedScrollvIEw.

这是一个例子Code

>在VIEw分页器片段中使用nestedScrollvIEw.>对于您的活动布局,将ScrollvIEw添加为根标签并添加androID:fillVIEwport =“true”

总结

以上是内存溢出为你收集整理的android – 在使用TabLayout和ViewPager的Fragment中启用滚动全部内容,希望文章能够帮你解决android – 在使用TabLayout和ViewPager的Fragment中启用滚动所遇到的程序开发问题。

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

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1126018.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存