2

так что я пытаюсь реализовать простую рушительную панель инструментов, но я не думаю, что мой xml-макет правильный. Текст появляется на изображении, и когда я прокручиваю вниз, я не могу выполнить прокрутку назад, чтобы увидеть изображение. Надеюсь, вы, ребята, можете помочь!Как сделать рушительную панель инструментов в android?

<?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" 
    tools:ignore="RtlHardcoded"> 
    <android.support.design.widget.AppBarLayout 
     android:id="@+id/cardInfo_appbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 
     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/cardInfo_collapsing" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"> 
      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:src="@drawable/image_kyoto"/> 
     </android.support.design.widget.CollapsingToolbarLayout> 
    </android.support.design.widget.AppBarLayout> 
    <android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 
      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="Hello there" 
       android:textSize="30dp"/> 
      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="Hello there" 
       android:textSize="30dp"/> 
      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="Hello there" 
       android:textSize="30dp"/>  <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Hello there" 
      android:textSize="30dp"/> 
     </LinearLayout> 
    </android.support.v4.widget.NestedScrollView> 
</android.support.design.widget.CoordinatorLayout> 

Вот изображение enter image description here

+0

Вы используете виджет CollapsingToolbarLayout, но у вас нет элемента панели инструментов в вашем xml. Это специально? – RustWebDev

ответ

2

Ваш ImageView должен иметь атрибут

app:layout_collapseMode="parallax" 

Если вы хотите добавить панель инструментов в вашем макете должен быть атрибут

app:layout_collapseMode="pin" 

И, наконец, вы пропустили один атрибут для NestedScrollView.

app:layout_behavior="@string/appbar_scrolling_view_behavior" 
3

в вашем ImageView, добавьте следующий атрибут:

app:layout_collapseMode="parallax" 

Кроме того, в вашем NestedScrollView тег, добавьте следующее:

app:layout_behavior="@string/appbar_scrolling_view_behavior" 
+0

Это сделало коллапс, но «Привет там тексты еще над изображением не под –

+0

нормально, попробуйте дать ваш AppBarLayout тег определенную высоту:?!? андроида: layout_height =» 250dp» – RustWebDev

+0

да что сделал трюк Не знаю, почему я не могу использовать wrap_content? –