У меня есть активность одного фрагмента. фрагмент имеет координаторский макет, который является прямым дочерним элементом и другими представлениями.Неправильное положение фабрики во фрагменте при запуске
Компоновка активность
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar_layout" />
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Фрагмент макета
<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:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.github.aakira.expandablelayout.ExpandableLinearLayout
android:id="@+id/statistic_expand_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/toolbar"
android:background="@color/colorPrimary"
android:orientation="vertical"
app:ael_duration="150"
app:ael_interpolator="accelerateDecelerate">
<com.github.mikephil.charting.charts.BarChart
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/overall_statistic_bar_chart"
android:layout_width="match_parent"
android:layout_height="@dimen/statistic_small"/>
<TextView
style="@style/SmallTextTheme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/spacing_small"
android:gravity="center"
android:text="@string/overall_statistic"
android:textColor="@color/colorTextPrimary"/>
</com.github.aakira.expandablelayout.ExpandableLinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/statistic_expand_layout"
android:scrollbars="vertical"/>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/spacing_tiny"
android:layout_below="@id/statistic_expand_layout"
android:background="@drawable/shadow_updown"/>
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/activity_main_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/spacing_standard"
android:src="@drawable/ic_add"
app:layout_anchor="@id/recycler_view"
app:layout_anchorGravity="bottom|end"/>
</android.support.design.widget.CoordinatorLayout>
Когда я начала деятельность с этого фрагмента ФАБ позиция неправильна
, но при нажатии на любую кнопку или представление fab переходит в правильное положение в r нижний угол. Когда я помещаю этот макет непосредственно в действие, позиция fab всегда правильная. Может ли кто-нибудь помочь мне разобраться, в чем проблема?
Здравствуйте, спасибо за ваш ответ, но я сделал ошибку в описании вопроса. Все в порядке, когда я ** помещаю фрагмент фрагмента непосредственно в активность ** на место фрагмента_контейнера, но когда ** я использую макет фрагмента как макет действия **. Мне нужен этот RelativeLayout для позиционирования RecyclerView в расширяемом макете, когда он расширяется. –
Почему вы не можете просто использовать 'CoordinatorLayout' внутри ** Activity Layout **, а затем положить' FloatingActionButton' в нужное место? Я просто думаю о том, почему вы помещаете 'Toolbar' в' LinearLayout', а затем для фрагмента, который вы используете 'CoordinatorLayout', без' Toolbar' и 'AppBarLayout' !! Я не думаю, правильно ли этот дизайн макета! – Mohsen
Вы правы, я переписал свой макет деятельности с компоновкой координатора, и теперь все в порядке. Спасибо :) –