Android 如何使用NestedScrollView
在我的应用程序中,我希望使用Android 如何使用NestedScrollView,android,android-layout,floating-action-button,Android,Android Layout,Floating Action Button,在我的应用程序中,我希望使用NestedScrollView进入DrawerLayout 为此,我写了下面的代码。 我想在布局的底部显示晶圆厂,但请在卡片的下方显示 我不想显示在下面的卡,我想显示底部的布局 请参见下图以理解我的意思: 我的代码: <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://s
NestedScrollView
进入DrawerLayout
为此,我写了下面的代码。
我想在布局的底部显示晶圆厂,但请在卡片的下方显示
我不想显示在下面的卡,我想显示底部的布局
请参见下图以理解我的意思: 我的代码:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/toNightDrawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="end">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/reviewSerialFrag_newsCommentsLay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible">
<android.support.v7.widget.CardView
android:id="@+id/reviewSerialFrag_newsCommentsCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/padding8"
ads:cardBackgroundColor="@android:color/white"
ads:cardElevation="@dimen/size2"
app:contentPadding="@dimen/padding8">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/reviewSerialFrag_newsCommentsHeaderLay"
android:layout_width="match_parent"
android:layout_height="@dimen/size50">
<ImageView
android:id="@+id/reviewSerialFrag_newsCommentsHeaderImage"
android:layout_width="@dimen/size35"
android:layout_height="@dimen/size35"
android:layout_centerVertical="true"
android:alpha="0.8"
android:src="@drawable/ic_comments"
android:tint="@color/darkBlueGrey" />
<TextView
android:id="@+id/reviewSerialFrag_newsCommentsUserTypeText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="@dimen/padding10"
android:layout_toRightOf="@+id/reviewSerialFrag_newsCommentsHeaderImage"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:textColor="@color/darkBlueGrey"
android:textSize="@dimen/font16" />
<TextView
android:id="@+id/reviewSerialFrag_newsCommentsReviewTypeText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="@dimen/padding10"
android:layout_toRightOf="@+id/reviewSerialFrag_newsCommentsUserTypeText"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:textColor="@color/darkBlueGrey"
android:textSize="@dimen/font14" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/reviewSerialFrag_newsCommentsRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/reviewSerialFrag_newsCommentsHeaderLay"
android:layout_marginTop="@dimen/padding5" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
<!--EmptyList-->
<RelativeLayout
android:id="@+id/reviewSerialFrag_EmptyLsy"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<include layout="@layout/empty_list" />
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/reviewSerialFrag_FilterBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="@dimen/padding15"
android:src="@drawable/ic_filter"
app:fabSize="normal" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.DrawerLayout>
如何解决此问题?请尝试这样做:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/toNightDrawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="end">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/reviewSerialFrag_newsCommentsLay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible">
<android.support.v7.widget.CardView
android:id="@+id/reviewSerialFrag_newsCommentsCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/padding8"
ads:cardBackgroundColor="@android:color/white"
ads:cardElevation="@dimen/size2"
app:contentPadding="@dimen/padding8">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/reviewSerialFrag_newsCommentsHeaderLay"
android:layout_width="match_parent"
android:layout_height="@dimen/size50">
<ImageView
android:id="@+id/reviewSerialFrag_newsCommentsHeaderImage"
android:layout_width="@dimen/size35"
android:layout_height="@dimen/size35"
android:layout_centerVertical="true"
android:alpha="0.8"
android:src="@drawable/ic_comments"
android:tint="@color/darkBlueGrey" />
<TextView
android:id="@+id/reviewSerialFrag_newsCommentsUserTypeText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="@dimen/padding10"
android:layout_toRightOf="@+id/reviewSerialFrag_newsCommentsHeaderImage"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:textColor="@color/darkBlueGrey"
android:textSize="@dimen/font16" />
<TextView
android:id="@+id/reviewSerialFrag_newsCommentsReviewTypeText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="@dimen/padding10"
android:layout_toRightOf="@+id/reviewSerialFrag_newsCommentsUserTypeText"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:textColor="@color/darkBlueGrey"
android:textSize="@dimen/font14" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/reviewSerialFrag_newsCommentsRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/reviewSerialFrag_newsCommentsHeaderLay"
android:layout_marginTop="@dimen/padding5" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
<!--EmptyList-->
<RelativeLayout
android:id="@+id/reviewSerialFrag_EmptyLsy"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<include layout="@layout/empty_list" />
</RelativeLayout>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/reviewSerialFrag_FilterBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/padding15"
android:src="@drawable/ic_filter"
app:fabSize="normal" />
</android.support.design.widget.CoordinatorLayout>
</android.support.v4.widget.DrawerLayout>
在协调器布局内设置所有内容,在nestedscrollview外设置fab。如果不起作用,请让我以其他可能的方式发送。
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/Widget.AppTheme.AppBarOverlay">
<include
layout="@layout/include_layout_toolbar_scroll"/>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/include_layout_content_with_nestedscroll"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_task_accept"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_accepted"
app:layout_behavior="pass.to.FabScrollBehavior.Class"
app:theme="@style/Widget.AppTheme.Fab"/>
< /android.support.design.widget.CoordinatorLayout>
嘿,伙计,试试这个代码:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/toNightDrawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="end">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/reviewSerialFrag_newsCommentsLay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible">
<android.support.v7.widget.CardView
android:id="@+id/reviewSerialFrag_newsCommentsCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/padding8"
ads:cardBackgroundColor="@android:color/white"
ads:cardElevation="@dimen/size2"
app:contentPadding="@dimen/padding8">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/reviewSerialFrag_newsCommentsHeaderLay"
android:layout_width="match_parent"
android:layout_height="@dimen/size50">
<ImageView
android:id="@+id/reviewSerialFrag_newsCommentsHeaderImage"
android:layout_width="@dimen/size35"
android:layout_height="@dimen/size35"
android:layout_centerVertical="true"
android:alpha="0.8"
android:src="@drawable/ic_comments"
android:tint="@color/darkBlueGrey" />
<TextView
android:id="@+id/reviewSerialFrag_newsCommentsUserTypeText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="@dimen/padding10"
android:layout_toRightOf="@+id/reviewSerialFrag_newsCommentsHeaderImage"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:textColor="@color/darkBlueGrey"
android:textSize="@dimen/font16" />
<TextView
android:id="@+id/reviewSerialFrag_newsCommentsReviewTypeText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="@dimen/padding10"
android:layout_toRightOf="@+id/reviewSerialFrag_newsCommentsUserTypeText"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:textColor="@color/darkBlueGrey"
android:textSize="@dimen/font14" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/reviewSerialFrag_newsCommentsRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/reviewSerialFrag_newsCommentsHeaderLay"
android:layout_marginTop="@dimen/padding5" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
<!--EmptyList-->
<RelativeLayout
android:id="@+id/reviewSerialFrag_EmptyLsy"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<include layout="@layout/empty_list" />
</RelativeLayout>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/reviewSerialFrag_FilterBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="@dimen/padding15"
android:src="@drawable/ic_filter"
app:fabSize="normal" />
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
我可以使用into CoordinatorLayout,但上面的代码有问题!请帮我输入以上代码my friendhey@hamid.Waezi您使用CoordinatorLayout,但上述问题与NestedScrollView有关。要在NestedScrollView中使用FAB,请使用下面的代码。我希望能帮上忙you@Kir没问题:)