Reputation: 359
what my problem is when user come on this screen it should be scroll the screen but some how its not scrolling? so this is my xml code which has scroll view inside CoordinatorLayout.
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:nestedScrollingEnabled="true"
android:background="@color/main_background_color"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_top_padding">
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00000000"
android:elevation="2dp"
android:minHeight="?attr/actionBarSize"
app:titleTextAppearance="@style/MaxxSports.ToolbarTextAppearance"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:elevation="2dp"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.AppBarLayout>
<ScrollView
android:id="@+id/al_svMainScroll"
android:layout_below="@id/appbar_layout"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/lf_cvInputContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:id="@+id/lf_firstNameInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:minHeight="72dp"
android:theme="@style/MaxxSports.TextInputLayout">
<android.support.design.widget.TextInputEditText
style="@style/MaxxSports.EditTextStyle"
android:focusableInTouchMode="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/lf_lastNameInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:minHeight="72dp"
android:theme="@style/MaxxSports.TextInputLayout">
<android.support.design.widget.TextInputEditText
style="@style/MaxxSports.EditTextStyle"
android:focusableInTouchMode="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/lf_emailInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:minHeight="72dp"
android:theme="@style/MaxxSports.TextInputLayout">
<android.support.design.widget.TextInputEditText
style="@style/MaxxSports.EditTextStyle"
android:focusableInTouchMode="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/lf_passwordInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:minHeight="72dp"
android:theme="@style/MaxxSports.TextInputLayout">
<android.support.design.widget.TextInputEditText
style="@style/MaxxSports.EditTextStyle"
android:focusableInTouchMode="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/lf_confirmPasswordInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:minHeight="72dp"
android:theme="@style/MaxxSports.TextInputLayout">
<android.support.design.widget.TextInputEditText
style="@style/MaxxSports.EditTextStyle"
android:focusableInTouchMode="true" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<!--</android.support.v7.widget.CardView>-->
<Button
android:id="@+id/lf_createAccountButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/lf_cvInputContainer"
android:layout_margin="16dp"
android:background="@drawable/sign_in_btn_bg"
android:elevation="5dp"
android:gravity="center"
android:text="Create Account"
android:textColor="#FFFFFF"
android:textSize="18sp" />
</RelativeLayout>
</ScrollView>
</android.support.design.widget.CoordinatorLayout>
so after trying so many things and work around still not found a solution ,any suggestion or where i was wrong please tell me.
Upvotes: 1
Views: 295
Reputation: 6857
You should use NestedScrollView
while working with CoordinatorLayout
.. and you are utilising layout behaviour of CoordinatorLayout
. Like below..
<android.support.design.widget.CoordinatorLayout
....
...>
<android.support.design.widget.AppBarLayout
....>
</android.support.design.widget.AppBarLayout>
<NestedScrollView
android:id="@+id/al_svMainScroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<!-- Your scrollring layout will go here -->
</NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
Upvotes: 0
Reputation: 69734
Try this
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:nestedScrollingEnabled="true"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00000000"
android:elevation="2dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:elevation="2dp"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.AppBarLayout>
<ScrollView
android:id="@+id/al_svMainScroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/appbar_layout"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/lf_cvInputContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:id="@+id/lf_firstNameInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:minHeight="72dp">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/lf_lastNameInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:minHeight="72dp">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/lf_emailInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:minHeight="72dp">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/lf_passwordInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:minHeight="72dp">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/lf_confirmPasswordInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:minHeight="72dp">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<!--</android.support.v7.widget.CardView>-->
<Button
android:id="@+id/lf_createAccountButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/lf_cvInputContainer"
android:layout_margin="16dp"
android:elevation="5dp"
android:gravity="center"
android:text="Create Account"
android:textColor="#FFFFFF"
android:textSize="18sp" />
</RelativeLayout>
</ScrollView>
</android.support.design.widget.CoordinatorLayout>
Upvotes: 1