Android 在AppBarLayout和NestedScrollView之间放置线性布局
我需要在AppBarLayout和NestedScrollView之间放置线性布局。Android 在AppBarLayout和NestedScrollView之间放置线性布局,android,xamarin,android-linearlayout,android-appcompat,nestedscrollview,Android,Xamarin,Android Linearlayout,Android Appcompat,Nestedscrollview,我需要在AppBarLayout和NestedScrollView之间放置线性布局。 澄清一下:它必须在嵌套的scrollview之外,在它上面 到目前为止,这是我做到的最好的行为: 古丁的回答是: 请注意,当我一直向上滚动时,布局是如何消失的。这也不应该发生 这是XML文件(用Gudin的答案更新) 谢谢:)发生的事情是,协调布局正在线性布局上方绘制工具栏。您需要将app:layout\u behavior=“@string/appbar\u scrolling\u view\u be
澄清一下:它必须在嵌套的scrollview之外,在它上面 到目前为止,这是我做到的最好的行为: 古丁的回答是: 请注意,当我一直向上滚动时,布局是如何消失的。这也不应该发生 这是XML文件(用Gudin的答案更新)
谢谢:)发生的事情是,
协调布局
正在线性布局
上方绘制工具栏
。您需要将app:layout\u behavior=“@string/appbar\u scrolling\u view\u behavior”
添加到您的LinearLayout
发生的事情是,协调布局
正在LinearLayout
上方绘制工具栏
。您需要将app:layout\u behavior=“@string/appbar\u scrolling\u view\u behavior”
添加到您的LinearLayout
如下使用:
<?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.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="250dp"
android:id="@+id/main.appbar"
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"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/placeholder"
android:scaleType="centerCrop"
android:id="@+id/image"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="80sp"
android:paddingTop="27sp"
app:layout_collapseMode="pin" />
</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"
android:background="#ffe5e5e5"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#ffffff"
android:id="@+id/linearback"
android:paddingTop="10dp">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_marginTop="15dp"
android:gravity="right">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Date:"
android:id="@+id/Datefetch"
android:textColor="#000000"
android:layout_gravity="end"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="01-01-2017"
android:textColor="#000000"
android:id="@+id/date"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:textColorHint="#000000"/>
</LinearLayout>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Info:"
android:textColor="#000000"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textSize="28sp"
android:paddingBottom="5dp"
/>
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/content1"
android:textColor="#000000"
android:layout_marginLeft="10dp"
android:textColorHint="#000000"
android:layout_marginRight="10dp"
android:hint="Your Content Here..........."
android:paddingBottom="5dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Games and Events:"
android:textColor="#000000"
android:textSize="28sp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:paddingBottom="5dp"
/>
<android.support.v7.widget.RecyclerView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/game_events_rec"
/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Venue:"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textColor="#000000"
android:textSize="28sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textColor="#000000"
android:id="@+id/venueeve"
/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_margin="@dimen/activity_horizontal_margin"
android:src="@drawable/my_library_add_black_48x48"
app:layout_anchor="@id/main.appbar"
android:id="@+id/addeventfab"
app:backgroundTint="#ffff11"
app:layout_anchorGravity="bottom|right|end"
/>
像这样使用:
<?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.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="250dp"
android:id="@+id/main.appbar"
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"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/placeholder"
android:scaleType="centerCrop"
android:id="@+id/image"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="80sp"
android:paddingTop="27sp"
app:layout_collapseMode="pin" />
</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"
android:background="#ffe5e5e5"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#ffffff"
android:id="@+id/linearback"
android:paddingTop="10dp">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_marginTop="15dp"
android:gravity="right">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Date:"
android:id="@+id/Datefetch"
android:textColor="#000000"
android:layout_gravity="end"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="01-01-2017"
android:textColor="#000000"
android:id="@+id/date"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:textColorHint="#000000"/>
</LinearLayout>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Info:"
android:textColor="#000000"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textSize="28sp"
android:paddingBottom="5dp"
/>
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/content1"
android:textColor="#000000"
android:layout_marginLeft="10dp"
android:textColorHint="#000000"
android:layout_marginRight="10dp"
android:hint="Your Content Here..........."
android:paddingBottom="5dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Games and Events:"
android:textColor="#000000"
android:textSize="28sp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:paddingBottom="5dp"
/>
<android.support.v7.widget.RecyclerView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/game_events_rec"
/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Venue:"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textColor="#000000"
android:textSize="28sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textColor="#000000"
android:id="@+id/venueeve"
/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_margin="@dimen/activity_horizontal_margin"
android:src="@drawable/my_library_add_black_48x48"
app:layout_anchor="@id/main.appbar"
android:id="@+id/addeventfab"
app:backgroundTint="#ffff11"
app:layout_anchorGravity="bottom|right|end"
/>
虽然这确实起到了作用,但唯一发生的事情是,现在线性布局不可见了。(可能包含在所有其他内容中)这个呢。使用
app:layout\u behavior=“@string/appbar\u scrolling\u view\u behavior”
创建另一个LinearLayout,并将其放在LinearLayout和NestedScrollView中。虽然这确实起到了作用,但现在唯一发生的事情是LinearLayout不可见。(可能包含在所有其他内容中)这个呢。使用app:layout\u behavior=“@string/appbar\u scrolling\u view\u behavior”
创建另一个LinearLayout,并将其放在LinearLayout和NestedScrollView中。这不是我的意思。linearlayout在ScrollView内部,我需要它在外部和上方。这不是我的意思。linearlayout位于ScrollView内部,我需要它位于外部和上方。