Проблемы с макетом координатора

Я не хочу, чтобы панель инструментов сворачивалась в макете координатора ниже. Что бы я ни делал, он рушится (вкладки не рушатся, но панель инструментов с заголовком сворачивается).

Вторая проблема заключается в том, что у вложенного прокрутки на странице просмотра есть несколько EditTexts. При открытии программной клавиатуры при щелчке по тексту редактирования внизу программная клавиатура проходит по тексту редактирования. При закрытии программной клавиатуры, а затем при второй попытке она успешно перемещает текст редактирования вверх.

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:layout_collapseMode="none">


    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

    <android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="36dp"
        android:paddingLeft="6dp"
        app:tabMode="scrollable" />

</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
    android:id="@+id/viewpager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="fill_vertical"
    android:layout_marginBottom="?attr/actionBarSize"/>

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    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_add_white_48dp"
    android:visibility="gone" />

This is one of the views within the viewpager:

<android.support.v4.widget.NestedScrollView 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"
    >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginLeft="22dp"
        android:layout_marginRight="22dp"
        android:layout_marginTop="15dp"
        android:orientation="vertical">


        <AutoCompleteTextView
            android:id="@+id/symbolAutoCompleteBuy"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:hint="Enter Symbol Here"
            android:inputType="textCapCharacters" />


        <TextView
            android:id="@+id/companyNameBuy"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp"
            android:layout_marginLeft="4dp"
            android:textColor="@color/gray2"
            android:textStyle="bold"
            android:textSize="14sp" />


        <TextView
            android:id="@+id/currentPriceBuy"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp"
            android:layout_marginLeft="4dp"
            android:textColor="@color/gray2"
            android:textStyle="bold"
            android:textSize="14sp" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:orientation="horizontal">

            <TextView
                android:layout_weight="0.45"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:text="PURCHASE PRICE"/>

            <EditText
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="0.55" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="80dp"
            android:orientation="horizontal">

            <TextView
                android:layout_weight="0.45"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:text="NUMBER OF SHARES"/>

            <EditText
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="0.55" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="18dp"
            android:orientation="horizontal">

            <TextView
                android:layout_weight="0.45"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:text="PURCHASE DATE"
                android:layout_gravity="center_vertical" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="0.35"
                android:id="@+id/dateText"
                android:layout_gravity="center_vertical" />

            <ImageView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="0.2"
                android:id="@+id/datePickerImage"
                android:src="@drawable/ic_event_note_black_24dp" />

        </LinearLayout>


    </LinearLayout>
</android.support.v4.widget.NestedScrollView>

person dejavu89    schedule 19.08.2015    source источник
comment
Почему вы используете AppBarLayout, когда вам явно не нужны его функции? Также вы должны задать только один вопрос. (Кроме того, второй вопрос был задан многим many много раз... Если бы вы только искали, прежде чем спрашивать...)   -  person Lamorak    schedule 19.08.2015
comment
Извините, я немного новичок как здесь, так и в программировании в целом. Поищу второй выпуск. Что касается первой проблемы, я удалил тег android.support.design.widget.AppBarLayout, но панель инструментов по-прежнему рушится. Если вы говорите о CoordinatorLayout, не могли бы вы предложить альтернативу, которая работает с viewpager?   -  person dejavu89    schedule 19.08.2015


Ответы (1)


Попробуй это

<android.support.design.widget.AppBarLayout
            android:id="@+id/app_bar_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">



<android.support.design.widget.CollapsingToolbarLayout
                android:id="@+id/collapsing_toolbar_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:contentScrim="@color/primary"
                app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="300dp"
                    android:scaleType="centerCrop"
                    android:src="@drawable/collapsing_toolbar_bg"
                    app:layout_collapseMode="parallax"/>


            <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
                    app:layout_collapseMode="pin"/>


</android.support.design.widget.CollapsingToolbarLayout>

<android.support.design.widget.TabLayout android:layout_width="match_parent"
                                                 android:layout_height="wrap_content"

                                                 android:id="@+id/tab_layout"
                                                 android:background="?attr/colorPrimary"/>

</android.support.design.widget.AppBarLayout>

Атрибут:

app:layout_scrollFlags="scroll|exitUntilCollapsed"

предотвращает полное свертывание макета сворачивающейся панели инструментов. И замените android:src="@drawable/collapsing_toolbar_bg" своим ресурсом изображения

person Collins Abitekaniza    schedule 05.09.2015