Привет, я создаю простую прокрутку в своем приложении для Android. Прокрутка acivity имеет CollapsingToolbarLayout с эффектом параллакса и плавающей кнопкой действия, привязанной к AppbarLayout.CollapsingToolbarLayout с ошибками FloatingActionButton
Когда я прокручиваю текст вниз, панель исчезает, и когда я прокручиваю ее назад, снова появляется кнопка плавающего действия.
В ошибки являются
1), когда floatingActionBar вновь появляется она расположена на нижнем конце страницы и после того, как второй она движется вверх в правильное положение (appbarlayout). 2) есть странный запас, который я не могу понять между панелью инструментов и содержимым страницы.
Поскольку это очень некрасиво видеть, что я хотел бы знать:
1.How я могу решить эту проблему? 2. Как я могу сохранить видимость и привязанность к свернутой панели инструментов?
Вот демо ошибка: http://i.giphy.com/LPMqLSl46Yvu0.gif
Вот мой макет:
<?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"
tools:context="toxotes.mystikon.EventActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_event"
android:layout_width="match_parent"
android:layout_height="200dp"
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="wrap_content"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:layout_width="match_parent"
android:layout_height="200dp"
app:layout_collapseMode="parallax"
android:src="@drawable/test"
android:scaleType="centerCrop"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_event"
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_event" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_event"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_media_play"
app:layout_anchor="@id/app_bar_event"
app:layout_anchorGravity="bottom|end" />
</android.support.design.widget.CoordinatorLayout>
Вот content_event расположение:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="toxotes.mystikon.EventActivity"
tools:showIn="@layout/activity_event">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin"
android:text="@string/large_text" />
</android.support.v4.widget.NestedScrollView>
Вот это Java:
public class EventActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_event);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_event);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab_event);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
}
}
Какой версией андроида поддержка дизайном вы используете? –
'com.android.support:design:24.2.0' –
Попробуйте «com.android.support:design:24.1.1» –