我使用support.v4.widget.NestedScrollView,我的webview有问题.
这是我的布局:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:id="@+id/barlayout">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:background="#9E9E9E"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/relativeLayout"
android:animateLayoutChanges="true">
<!-- some views here -->
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<WebView
android:id="@+id/webView"
android:layout_height="match_parent"
android:layout_width="match_parent" />
</android.support.v4.widget.NestedScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBar"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"/>
<include
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="@layout/dialog_location"
android:id="@+id/dialog"
android:visibility="invisible"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
有了这个布局,webview必须滚动很多(抱歉链接,我无法发布图片)
https://drive.google.com/open?id=0B7otV-_1sdEvUWRzSjlHY01fY3c
如果我将webview更改为wrap_content,则webview很小
<WebView
android:id="@+id/webView"
android:layout_height="wrap_content"
android:layout_width="match_parent" />
Run Code Online (Sandbox Code Playgroud)
https://drive.google.com/open?id=0B7otV-_1sdEvbVFSRlR0a2IxeUk
android webview coordinator-layout android-coordinatorlayout nestedscrollview
这是我的 layout
________________ ___
| | ||
| Linear | ||
| Layout | ||
| | || nested scroll view
|______________| ||
|| || ||
|| || ||
|| Child || _||
||Recyclerview||
||____________||
|______________| -end
Run Code Online (Sandbox Code Playgroud)
如何使父级LinearLayout先滚动,到达末尾时,子级recyclerview应该滚动。
默认情况下RecyclerView,在父级开始滚动之前,子级首先滚动到结尾。
android android-scrollview android-recyclerview nestedscrollview
我有:1.Coordinator布局2.appbar布局(协调器布局的子)3.Collapsing工具栏布局(app栏的子)4.NestedScrollView(协调员的子)
我想在里面放一个网格视图,NestedScrollView以便用户可以滚动整个屏幕空间.
我的问题是,目前gridview占据了该部分内部的一小部分NestedScrollView而不是完整空间NestedScrollView并在该部分内滚动,如下图所示:
正如您所看到的,我的gridview高度仅限于天蓝色中突出显示的部分,我希望它占据该图像下方的整个屏幕空间(这是我的折叠工具栏).我尝试了不同的方法但没有任何效果.我的xml文件是:
<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:id="@+id/app_bar"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="196dp"
android:background="#3f51b5"
app:contentScrim="@color/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/imageview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/index"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<GridView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:id="@+id/gridView"
android:verticalSpacing="1dp"
android:horizontalSpacing="1dp"
android:numColumns="2"
android:stretchMode="columnWidth"/>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|bottom"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email" />
Run Code Online (Sandbox Code Playgroud)
我正在嵌套滚动视图中添加卡片。对于 LinearLayout 中顺序较低的卡片,卡片高度会自动增加。要了解该问题,请注意第一张卡片和最后一张卡片之间的卡片高度。尽管卡片相同,但最后一张卡片的阴影比第一张卡片的阴影更深。如何解决?
使用 appcompat v7:22.+ 作为 v7 库的依赖项。
这是我的卡片视图布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardElevation="1dp"
android:layout_marginBottom="10dp"
card_view:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_margin="10dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="@+id/hint"
android:layout_width="0dp"
android:text="ABC"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="@color/textHint"/>
<TextView
android:id="@+id/description"
android:layout_width="0dp"
android:text="DEFG BHJHKJ"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="1"/>
</LinearLayout>
</android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud)
这就是我使用卡片视图的方式:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="200dp"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsingtoolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleTextAppearance="@android:color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<include
layout="@layout/shared_activity_item"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:contentInsetStart="0dp"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> …Run Code Online (Sandbox Code Playgroud) android android-scrollview android-cardview android-elevation nestedscrollview
我有一个布局,其中包含可折叠的图像视图,以及布局中的GridView,以及UI中的更多内容.但是屏幕滚动到图像滚动,即它只向上滚动直到标题图像不可见.之后它既不滚动也不滚动.
我怎么解决这个问题?
这是我的布局:
父布局:
<?xml version="1.0" encoding="utf-8"?>
<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:fitsSystemWindows="true"
>
<android.support.design.widget.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapse_toolbar"
android:layout_width="match_parent"
android:layout_height="256dp"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/headerImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
android:src="@drawable/gallery_shop"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:gravity="top"
android:minHeight="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:titleMarginTop="15dp" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fabCall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
app:layout_anchor="@id/appBar"
android:clickable="true"
app:layout_anchorGravity="bottom|right|end"
android:src="@drawable/telephone_call" />
<include
layout="@layout/content_shop_products_category"/>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
包含的布局:
[![<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
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:layout_gravity="fill_vertical"
android:layout_margin="5dp"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android" …Run Code Online (Sandbox Code Playgroud) 我已经使用 Android Studio 模板创建了一个 Scrolling Activity,这创建了一个 activity.xml 和一个 content.xml,它包含在具有 NestedScrollView 的 activity.xml 中,我在其中添加了来自适配器的 ListView 提要,起初它只显示一个项目,所以我以编程方式将它的大小设置为固定值,以便它实际上显示所有项目,我能够毫无问题地做到这一点,并且 NestedScrollView 毫无问题地包装了 ListView,但是有通过向所有元素添加背景颜色,我意识到 NestedScrollView 下方的空白区域来自 CoordinatorLayout,CoordinatorLayout 是活动中的主要标签。xml,但我无法弄清楚如何删除这个空白空间,因为如果我在 CoordinatorLayout 上使用 wrap_content ,它实际上会出于某种原因将我的内容修剪到屏幕的一半。
其他值得一提的是,如果我水平旋转手机,这个空白空间不会显示,只会出现在垂直位置。还,
有谁知道这可能是什么原因造成的?没什么大不了的,我什至可能会像这样离开它,但这对我来说很烦人,我无法弄清楚发生了什么。
这是我的activity.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true"
android:background="#00ff00" //Green
tools:context=".VenueActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/frog"
android:scaleType="centerCrop"
/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_venue"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_favorite_white_24dp"
app:layout_anchor="@id/app_bar"
app:layout_anchorGravity="bottom|end" …Run Code Online (Sandbox Code Playgroud) android android-scrollview android-studio android-coordinatorlayout nestedscrollview
当其中一个tabView滚动到顶部时(显示sliverAppBar),tabView的滚动位置无法正确还原。另一个tabView也将滚动到顶部(失去其先前的滚动位置)。
使用可折叠的应用程序栏(sliverAppBar)时如何保留tabView的滚动位置?
import 'package:flutter/material.dart';
void main() {
runApp(new MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new DefaultTabController(
length: 2,
child: Scaffold(
body: NestedScrollView(
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverAppBar(
title: Text('Example'),
pinned: true,
floating: true,
forceElevated: innerBoxIsScrolled,
bottom: …Run Code Online (Sandbox Code Playgroud) scroll-position nestedscrollview flutter flutter-sliver flutter-layout
这似乎很自然,甚至可能是预料之中的,但我仍然没有找到任何可能有帮助的东西。我在另一个可滚动小部件(父级)中有一个 ScrollablePositionedList (几乎与 ListView 相同)(我尝试过 CustomScrollView 和 ListView,甚至 NestedScrollView),我想让它看起来这样,当我滚动到子项的顶部时可滚动并仍然滑动我实际上在父可滚动中滚动。非常欢迎任何帮助,谢谢!
基本上我想在这里完成的是拥有一个水平类别列表(可以是 TabBar)和一个垂直类别列表,每个类别中都有项目列表。
当您单击某个类别时,它应该滚动到类别垂直列表中的某个位置。当您滚动垂直列表时,顶部的活动类别也应该更新当前的活动类别。
我在 FoodPanda 应用程序中看到过此功能,但无法复制它。
关于如何实现此功能有什么建议吗?
我正在尝试制作一个在移动设备和桌面设备上运行良好的响应式页面。我在 NestedScrollView 中使用 SliverAppBar。问题是 NestedScrollView 中完全忽略了对容器的 maxwidth 约束。此行为也与 CustomScrollView 相同。
如何限制 NestedScrollView 主体小部件中容器的大小。
下面是代码:
import "dart:math";
import "package:flutter/material.dart";
class ResponsiveSliver extends StatefulWidget {
static const routeName = 'responsive-sliver';
@override
_ResponsiveSliverState createState() => _ResponsiveSliverState();
}
class _ResponsiveSliverState extends State<ResponsiveSliver> with SingleTickerProviderStateMixin {
@override
Widget build(BuildContext context) {
return Scaffold(
body: NestedScrollView(
floatHeaderSlivers: true,
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverAppBar(
title: Text(
"Responsive Sliver",
),
centerTitle: true,
pinned: true,
floating: true,
),
];
},
body: ConstrainedBox(
constraints: BoxConstraints(maxWidth: 200), …Run Code Online (Sandbox Code Playgroud) nestedscrollview flutter responsive customscrollview sliverappbar
nestedscrollview ×10
android ×6
flutter ×4
gridview ×1
listview ×1
responsive ×1
scroll ×1
sliverappbar ×1
webview ×1