Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 在使用TabLayout和ViewPager的Fragment中启用滚动大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_673_0@
@H_673_0@
你好!
我希望这个视图可以滚动:

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

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

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

这是持有视图的布局:

<?xml version="1.0" encoding="utf-8"?>

    <LinearLayout xmlns:android="http://scheR_932_11845@as.android.com/apk/res/android"
        xmlns:app="http://scheR_932_11845@as.android.com/apk/res-auto"
        xmlns:tools="http://scheR_932_11845@as.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        app:layouT_Behavior="@@R_616_10495@ng/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://scheR_932_11845@as.android.com/apk/res/android"
    xmlns:tools="http://scheR_932_11845@as.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”

@H_673_0@

大佬总结

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

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

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:androidfragmenttablayout启用在使滚动
猜你在找的Android相关文章
其他相关热搜词更多
phpJavaPython程序员load如何string使用参数jquery开发安装listlinuxiosandroid工具javascriptcap