Joh*_*y19 1 android dynamic behind nestedscrollview
我实现了类似的设计 https://github.com/chrisbanes/cheesesquare
一个可折叠的工具栏,其中的图像在向下滚动时会折叠
<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.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
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/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="@dimen/picture_heigth"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax">
</android.support.v4.view.ViewPager>
<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/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/scroll_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:foreground="?android:windowContentOverlay"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
LinearLayout
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
Run Code Online (Sandbox Code Playgroud)
它很有用,但并不总是......例如,在线性布局中我有一个视图,在我的休息请求完成后被填充.这有效地推动了Viewpager的内容,当我再向下滚动时,一切都会再次进入正确的位置.
我在一些SO线程上看到,通过在NestedSCrollVew上设置"fill_vertical",它解决了一些问题.它实际上,内容不会落后但是scrollView的底部是CUT ...通过设置一些底部边距它解决了问题,但它是动态的我不知道提前什么边缘...
小智 7
添加到LinearLayout焦点属性:
android:focusable="true"
android:focusableInTouchMode="true"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1991 次 |
| 最近记录: |