(app)ScrollView在移动端无效问题

(app)ScrollView在移动端无效问题

(scroll-view)小程序有效,app无效

在这里插入图片描述

<!-- 分类导航 -->
<scroll-view class="navScroll"  enable-flex scroll-x >
	<view class="navItem" v-for="(item, index) in navItemList" :key="item.id" >
		<view :class="navId == item.id?'navContent active': 'navContent'" @click="changeNav" :id="item.id" >{{item.value}}</view>
	</view>
</scroll-view>
(Horizontal-scroll-view)都有效

在这里插入图片描述

<!-- 分类导航 --> 
<Horizontal-scroll-view class="navScroll"  enable-flex scroll-x >
	<view class="navItem" v-for="(item, index) in navItemList" :key="item.id" >
		<view :class="navId == item.id?'navContent active': 'navContent'" @click="changeNav" :id="item.id" >{{item.value}}</view>
	</view>
</Horizontal-scroll-view>

解决参考:https://blog.csdn.net/fumin466566941/article/details/52872063?spm=1001.2101.3001.6650.17&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-17-52872063-blog-105169150.pc_relevant_3mothn_strategy_and_data_recovery&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-17-52872063-blog-105169150.pc_relevant_3mothn_strategy_and_data_recovery&utm_relevant_index=25

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要将TabLayout固定在ScrollView的顶部,可以使用以下方法: 1. 使用CoordinatorLayout和AppBarLayout 将ScrollView作为CoordinatorLayout的子视图,并将AppBarLayout作为ScrollView的直接父视图。在AppBarLayout中添加TabLayout和Toolbar,然后使用app:layout_scrollFlags属性将Toolbar和TabLayout与ScrollView关联起来。 例如: ``` <androidx.coordinatorlayout.widget.CoordinatorLayout android:layout_width="match_parent" android:layout_height="match_parent"> <com.google.android.material.appbar.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <com.google.android.material.appbar.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:layout_scrollFlags="scroll|enterAlways"> <!-- Toolbar content --> </com.google.android.material.appbar.Toolbar> <com.google.android.material.tabs.TabLayout android:id="@+id/tab_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/colorPrimary" app:tabGravity="fill" app:tabMode="fixed"> <!-- TabLayout content --> </com.google.android.material.tabs.TabLayout> </com.google.android.material.appbar.AppBarLayout> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <!-- ScrollView content --> </ScrollView> </androidx.coordinatorlayout.widget.CoordinatorLayout> ``` 2. 使用NestedScrollView和LinearLayout 将TabLayout和ScrollView放在一个LinearLayout中,然后将LinearLayout放在NestedScrollView中。在TabLayout中添加app:layout_scrollFlags属性,并将其设置为scroll|enterAlways。 例如: ``` <androidx.core.widget.NestedScrollView android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <com.google.android.material.tabs.TabLayout android:id="@+id/tab_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/colorPrimary" app:layout_scrollFlags="scroll|enterAlways" app:tabGravity="fill" app:tabMode="fixed"> <!-- TabLayout content --> </com.google.android.material.tabs.TabLayout> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent"> <!-- ScrollView content --> </ScrollView> </LinearLayout> </androidx.core.widget.NestedScrollView> ``` 注意:在使用第二种方法时,TabLayout必须是LinearLayout的第一个子视图。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值