0

I do not want the toolbar to collapse in the coordinator layout below. No matter what I do it collapses (the tabs do not collapse but the toolbar with the title does).

Second issue is that the nestedscrollview in the viewpager has a few EditTexts. On opening of softkeyboard when an edittext at the bottom is clicked the softkeyboard goes over the edittext. On closing the softkeyboard and then doing second attempt it successfully moves the edittext text up.

<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>
dejavu89
  • 754
  • 1
  • 7
  • 17
  • 1
    Why do you use `AppBarLayout` when you clearly don't need its features? Also you should ask only one question. (Moreover, the second question has been asked [many](http://stackoverflow.com/questions/24262414/android-keyboard-hides-edittext) [many](http://stackoverflow.com/questions/3295672/android-soft-keyboard-covers-edittext-field) [many](http://stackoverflow.com/questions/20128193/soft-keyboard-hides-half-of-edittext) times... If only you had searched before asking...) – Lamorak Aug 19 '15 at 17:02
  • I'm sorry I'm a little new to both here and programming in general. I'll look up the second issue. Regarding the first issue, I removed "android.support.design.widget.AppBarLayout" tag but the toolbar still collapses. If you are talking about the CoordinatorLayout can you please suggest an alternative which works with viewpager? – dejavu89 Aug 19 '15 at 17:12

1 Answers1

0

Try this

<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>

The atrribute:

app:layout_scrollFlags="scroll|exitUntilCollapsed"

prevents the collapsing toolbar layout from getting completely collapsed. And replace android:src="@drawable/collapsing_toolbar_bg" with your image resource

Collins Abitekaniza
  • 4,496
  • 2
  • 28
  • 43