i need to parallax my image in activity_scrolling.xml with the content of content_scrolling.xml. i have included the contents using <include layout="#layout/content_scrolling" />.And the action bar here i used is fading one. and i have included a screenshot also img
here is the code of activity_scrolling.xml
<?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=".ScrollingActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar"
android:fitsSystemWindows="true"
android:layout_height="300dp"
android:background="#drawable/pweek1"
android:layout_width="match_parent"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/toolbar_layout"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:contentScrim="?attr/colorPrimary">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"
app:layout_collapseMode="pin"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_scrolling" />
</android.support.design.widget.CoordinatorLayout>
heres code of content_scrolling.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:showIn="#layout/activity_scrolling" android:layout_width="match_parent"
android:layout_height="match_parent" tools:context=".ScrollingActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView4"
android:layout_width="match_parent"
android:text="INGREDIENTS"
android:layout_height="wrap_content"
android:paddingLeft="20dp"
android:paddingRight="15dp"
android:gravity="left"
/>
<LinearLayout
android:layout_width="match_parent"
android:id="#+id/ingredients"
android:layout_height="wrap_content"
android:layout_below="#+id/textView4"
android:layout_marginTop="15dp"
>
<ListView
android:id="#+id/inglist"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:divider="#DDDDDD"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/nutfacts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/ingredients"
android:orientation="horizontal"
android:layout_marginBottom="10dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:weightSum="4">
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:background="#8b1e1e"
android:layout_height="100dp"
android:layout_weight="1"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:weightSum="2" >
<TextView
android:id="#+id/caltext"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#000000"
android:gravity="center"
android:textSize="20dp"
android:layout_weight="1"/>
<TextView
android:id="#+id/caltext2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#000000"
android:gravity="center"
android:layout_weight="1"/>
</LinearLayout>
<ImageView
android:id="#+id/imageView2"
android:layout_width="match_parent"
android:background="#8b1e1e"
android:layout_height="100dp"
android:layout_weight="1"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:weightSum="2"
android:layout_marginRight="10dp">
<TextView
android:id="#+id/sertext"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:textSize="20dp"
android:textColor="#000000"
android:layout_weight="1"/>
<TextView
android:id="#+id/sertext2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#000000"
android:gravity="center"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/nutfacts"
android:gravity="left"
android:text="Direction Of Use"
android:paddingLeft="20dp"
android:paddingRight="15dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
/>
<TextView
android:id="#+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="#string/large_text"
android:layout_below="#+id/textView5"
android:paddingLeft="15dp"
android:paddingRight="15dp"
/>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
Related
I create Layout which consists
CoordinatorLayout
AppBarLayout
CollapsingToolbarLayout
Image
Toolbar
and include one layout for content.
Why the content layout when scroll up is over the toolbar?
This is pic first open Activity
This is pic first open Activity
when scroll down
and scroll up
main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.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"
tools:context=".Activity_Movie">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="#dimen/detail_backdrop_height"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="#+id/backdrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
app:srcCompat="#drawable/a_poster_joker" />
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<include layout="#layout/content_activity__movie" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
content_activity__movie.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.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:id="#+id/Movie_Nested"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="false"
android:fillViewport="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".Activity_Movie"
tools:showIn="#layout/p__movie">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="false"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:orientation="vertical">
<TextView
android:id="#+id/Movie_Title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Title"
android:textColor="#color/colorPrimary"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dip"
android:orientation="horizontal">
<LinearLayout
android:layout_width="160dip"
android:layout_height="200dip"
android:orientation="horizontal"
android:padding="5dip">
<ImageView
android:id="#+id/Movie_Img"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:srcCompat="#tools:sample/avatars[3]" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dip"
android:orientation="vertical"
android:padding="10dip">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Score"
android:textColor="#color/colorBlack"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<com.mancj.slimchart.SlimChart
android:id="#+id/slimChart"
android:layout_width="80dip"
android:layout_height="80dip"
app:roundedEdges="true"
app:strokeWidth="8dp"
app:text="0"
app:textColor="#color/colorAccent" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Genre"
android:textColor="#color/colorBlack"
android:textStyle="bold" />
<TextView
android:id="#+id/Movie_Genre"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ACTION"
android:textColor="#color/colorBlack" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Release Date"
android:textColor="#color/colorBlack"
android:textStyle="bold" />
<TextView
android:id="#+id/Movie_Release"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="2019-11-02"
android:textColor="#color/colorBlack" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dip"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sinopsis"
android:textColor="#color/colorBlack"
android:textStyle="bold" />
<TextView
android:id="#+id/Movie_Sinopsis"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=". . . . . "
android:textColor="#color/colorBlack" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dip"
android:layout_marginBottom="10dip"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/colorPrimary"
android:orientation="horizontal"
android:padding="5dip">
<TextView
android:id="#+id/Movie_Label_Other"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Movie Action Lainnya"
android:textColor="#color/colorWhite"
android:textStyle="bold" />
</LinearLayout>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:animationCache="true"
android:elevation="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="5dip"
android:orientation="horizontal">
<GridView
android:id="#+id/Movie_Grid"
android:layout_width="1050dip"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginTop="10dip"
android:layout_marginRight="10dip"
android:layout_marginBottom="10dip"
android:columnWidth="100dip"
android:elevation="5dip"
android:gravity="center"
android:horizontalSpacing="5dip"
android:numColumns="10"
android:scrollbars="horizontal"
android:stretchMode="none"
android:verticalSpacing="5dip" />
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
use this tag into toolbar :
app:layout_scrollFlags="scroll|enterAlways|snap"
hope it will help you.
I've got a Webview and a Toolbar. Without the Toolbar, the Webview is completely scollable, but when I add the Toolbar the the Webview doesn't scroll anymore. I've tried NestedScrollView but it just doesn't work. Here's the layout of my activity:
<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.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="100">
<ImageButton
android:id="#+id/homeButton"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="20"
android:contentDescription="#string/home"
app:srcCompat="#drawable/ic_home" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="60"
android:gravity="center"
android:text="#string/app_name"
android:textSize="24sp"
android:textStyle="bold"
app:fontFamily="Sans Serif" />
<ImageButton
android:id="#+id/menuButton"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="20"
android:contentDescription="#string/menu"
app:srcCompat="#drawable/ic_menu_black_24dp" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
<RelativeLayout
android:id="#+id/relative"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MailActivity">
<WebView
android:id="#+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior"/>
</RelativeLayout>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
The Java code for the Toolbar simply creates the menu and the home button, while the webview simply loads an url (javascript is enabled).
Thanks a lot for your help!
<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.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="100">
<ImageButton
android:id="#+id/homeButton"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="20"
android:contentDescription="#string/home"
app:srcCompat="#drawable/ic_home" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="60"
android:gravity="center"
android:text="#string/app_name"
android:textSize="24sp"
android:textStyle="bold"
app:fontFamily="Sans Serif" />
<ImageButton
android:id="#+id/menuButton"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="20"
android:contentDescription="#string/menu"
app:srcCompat="#drawable/ic_menu_black_24dp" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<WebView
android:id="#+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
You have to move Relative layout outside of the Appbar.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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:orientation="vertical"
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.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="100">
<ImageButton
android:id="#+id/homeButton"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="20"
android:contentDescription="#string/home"
app:srcCompat="#drawable/ic_home" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="60"
android:gravity="center"
android:text="#string/app_name"
android:textSize="24sp"
android:textStyle="bold"
app:fontFamily="Sans Serif" />
<ImageButton
android:id="#+id/menuButton"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="20"
android:contentDescription="#string/menu"
app:srcCompat="#drawable/ic_menu_black_24dp" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<WebView
android:id="#+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"/>
</LinearLayout>
I'm adding a BottomNavigationView to My MainActivity
at first show nothing wrong but after click on other items, BottomNavigationView strangely moving up and down. In other projects, I had never this problem and I don't know why I am getting this:
p.s: In default fragment (which is first at right in screenshot) I have a content but in other fragments, I have no content.
Here is my MainActivity layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context="com.activity.MainActivity">
<FrameLayout
android:id="#+id/MainActivity_FrameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/MainActivity_BottomView" />
<android.support.design.widget.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/colorPrimary"
app:menu="#menu/main_bottom_view_menu"
app:elevation="2dp"
app:itemTextColor="#android:color/white"
app:itemIconTint="#android:color/white"
android:id="#+id/MainActivity_BottomView"/>
</RelativeLayout>
and here is the screenshot of how does shown
after clicking on another item
and when select default item again
--- EDIT ---
I realized it's happen when use CoordinatorLayout , AppBarLayout and CollapsingToolbarLayout in fragment . After remove that lines app work without any problem .
Here is my fragment Layout :
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#e2e2e2"
android:animateLayoutChanges="true"
android:fitsSystemWindows="true"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.fragment.MainFragments.ProfileFragment">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:background="#color/colorPrimaryDark"
android:layout_height="wrap_content">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimaryDark"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
app:titleEnabled="false"
app:scrimAnimationDuration="300"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:background="#color/colorPrimaryDark"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="140dp"
android:gravity="center_horizontal"
android:orientation="vertical"
android:id="#+id/Profile_InfoContainer"
android:layout_centerHorizontal="true"
android:layout_height="wrap_content">
<com.graymind.applog.customview.CircleImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:id="#+id/Profile_ProfilePhoto"
android:layout_marginTop="10dp"
android:scaleType="centerCrop"
app:srcCompat="#drawable/login_bg"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="25dp"
android:textColor="#android:color/white"
android:gravity="center"
android:id="#+id/Profile_FullName"
android:text="FullName"
android:textStyle="bold"/>
<TextView
android:id="#+id/Profile_Id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="'#gray_mind75"
android:textColor="#android:color/white"
android:textStyle="normal" />
</LinearLayout>
<TextView
android:id="#+id/Profile_Bio"
android:layout_width="match_parent"
android:layout_below="#+id/Profile_InfoContainer"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:layout_marginBottom="10dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:textSize="12sp"
android:lineSpacingExtra="4sp"/>
android:textColor="#android:color/white"
android:textDirection="rtl" />
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:weightSum="3"
android:layout_below="#+id/Profile_Bio"
android:layout_height="50dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="5dp"
android:weightSum="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:text="1234"
android:textColor="#android:color/white"
android:textSize="#dimen/profile_stats_texts_size"
android:gravity="center"
tools:ignore="NestedWeights" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:textSize="#dimen/profile_stats_texts_size"
android:textColor="#android:color/white"
android:gravity="center"
android:text="#string/post"/>
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#color/colorPrimary"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="5dp"
android:weightSum="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:text="1234"
android:textSize="#dimen/profile_stats_texts_size"
android:textColor="#android:color/white"
android:gravity="center"
tools:ignore="NestedWeights" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:textColor="#android:color/white"
android:textSize="#dimen/profile_stats_texts_size"
android:gravity="center"
android:text="#string/followings"/>
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#color/colorPrimary"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="5dp"
android:weightSum="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:text="1234"
android:textSize="#dimen/profile_stats_texts_size"
android:textColor="#android:color/white"
android:gravity="center"
tools:ignore="NestedWeights" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:textSize="#dimen/profile_stats_texts_size"
android:textColor="#android:color/white"
android:gravity="center"
android:text="#string/followers"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
app:layout_collapseMode="pin"
android:layout_height="?attr/actionBarSize">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="#string/profile"
android:gravity="center"
android:layout_toStartOf="#+id/Profile_ToolbarProfileIcon"
android:textColor="#android:color/white"
android:layout_marginEnd="10dp"/>
<ImageView
android:layout_width="30dp"
android:layout_marginEnd="10dp"
android:padding="5dp"
android:id="#+id/Profile_ToolbarProfileIcon"
android:layout_height="match_parent"
app:srcCompat="#drawable/ic_profile"
android:tint="#android:color/white"
android:layout_alignParentEnd="true"/>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:id="#+id/ProfilePostsScrollView"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:requiresFadingEdge="none"
android:id="#+id/Profile_PostsRecycler"/>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
Thanks in advance for your guidance.
Change your root layout to LinearLayout like below:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
tools:context="com.activity.MainActivity">
<FrameLayout
android:id="#+id/MainActivity_FrameLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<android.support.design.widget.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
app:menu="#menu/main_bottom_view_menu"
app:elevation="2dp"
app:itemTextColor="#android:color/white"
app:itemIconTint="#android:color/white"
android:id="#+id/MainActivity_BottomView" />
</LinearLayout>
I am tying to add image in a Fragment with image at the top and parallax effect when scrolled down. I tried doing this using Collapsible Toolbar, but image is not filling up the Collapsible Toolbar, and parallax is not working.
I want something like this
But this is what I achieved till now.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
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"
xmlns:card_view="http://schemas.android.com/tools"
android:id="#+id/drawerlayout1">
<android.support.design.widget.CoordinatorLayout
android:id="#+id/coordinatorlayout"
android:layout_width="fill_parent"
android:layout_height="match_parent"
app:expandedTitleMarginStart="70dp">
<android.support.design.widget.AppBarLayout
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:layout_width="fill_parent"
android:id="#+id/actionbarlayout"
android:layout_height="207dp">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/CollapsingToolbarLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:contentScrim="#color/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:id="#+id/details_Image"
app:layout_collapseMode="parallax"
/>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar1"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_collapseMode="pin"
android:minHeight="?attr/actionBarSize"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardElevation="3dp"
card_view:cardCornerRadius="7dp"
android:layout_margin="5dp"
android:id="#+id/new_order"
card_view:cardBackgroundColor="#color/cardview_shadow_end_color"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:layout_marginTop="15dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/download"
android:background="#null"
android:src="#drawable/ic_action_ic_file_download_white_36dp"
android:layout_centerInParent="true"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/favourite"
android:layout_centerInParent="true"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/zoom"
android:background="#null"
android:src="#drawable/ic_action_ic_zoom_out_map_white_36dp"
android:layout_centerInParent="true"
/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/imageDescription"
android:text="keckwcbjbewbcbcbcwjbejwkbcwkbcbwjc"
/>
</ScrollView>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone"
android:id="#+id/fullimage"/>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.CoordinatorLayout
android:id="#+id/coordinatorlayout"
android:layout_width="fill_parent"
android:layout_height="match_parent"
app:expandedTitleMarginStart="70dp">
<android.support.design.widget.AppBarLayout
android:id="#+id/actionbarlayout"
android:layout_width="fill_parent"
android:layout_height="207dp"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/CollapsingToolbarLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="#color/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="#+id/details_Image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:background="#color/colorAccent"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar1"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:minHeight="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="#+id/new_order"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
card_view:cardBackgroundColor="#color/cardview_shadow_end_color"
card_view:cardCornerRadius="7dp"
card_view:cardElevation="3dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:gravity="center"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageButton
android:id="#+id/download"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/ic_action_ic_file_download_white_36dp"
android:background="#null" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:id="#+id/favourite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageButton
android:id="#+id/zoom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/ic_action_ic_zoom_out_map_white_36dp"
android:background="#null" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp">
<TextView
android:id="#+id/imageDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="keckwcbjbewbcbcbcwjbejwkbcwkbcbwjc"
/>
</ScrollView>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<ImageView
android:id="#+id/fullimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone" />
</android.support.design.widget.CoordinatorLayout>
Replace your code with this.
I am new to CollapsingToolbarLayout when i scroll my content was not scroll smoothly any one please help where i did wrong were below my layout,when i scrooll up it my layout was not scrolling smoothly
<android.support.design.widget.AppBarLayout android:layout_height="wrap_content"
android:layout_width="match_parent" android:theme="#style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp" >
<ImageView
android:id="#+id/fulldec_image"
android:layout_width="match_parent"
android:layout_height="350dp"
android:scaleType="fitXY"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"
/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="170dp"
android:layout_gravity="bottom">
<TextView
android:id="#+id/fulldectext"
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_gravity="center"
android:text="The problem is not the problem. The problem is your attitude about the problem"
android:textSize="25sp"
android:lineSpacingMultiplier="1.2"
android:gravity="center"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/fullde_descriptiontect"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:text="Hello"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="20dp"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="130dp"
android:paddingLeft="30dp"
android:background="#FFFFFF"
android:orientation="vertical">
<TextView
android:layout_marginLeft="10dp"
android:gravity="center_vertical"
android:text="More Links"
android:layout_width="fill_parent"
android:layout_height="35dp"
android:textStyle="bold"
android:textSize="15dp"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/text_one_t"
android:gravity="center"
android:layout_marginTop="10dp"
android:textSize="20dp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
<TextView
android:id="#+id/text_two_t
android:layout_marginTop="10dp"
android:textSize="20dp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>