Skip to content

Instantly share code, notes, and snippets.

@petersaints
Created April 26, 2016 14:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petersaints/0f6e70c3aa016791b10b13023a83a264 to your computer and use it in GitHub Desktop.
Save petersaints/0f6e70c3aa016791b10b13023a83a264 to your computer and use it in GitHub Desktop.
Android Scrolling Activity Example
<?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="pt.unl.fct.di.novalincs.yanux.scavenger.ScrollingActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
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.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email"
app:layout_anchor="@id/app_bar"
app:layout_anchorGravity="bottom|end" />
</android.support.design.widget.CoordinatorLayout>
@petersaints
Copy link
Author

@1224hinduja
What do you mean by output? This is just an Android XML Layout file. It doesn't generate any text output that I can post.
The only thing that I could post is a screenshot/video of what this does. But to be honest, I'm not 100% sure that I even have a project laying around that uses this piece of code (I kind forgot about it). But if that's want you need I can make a quick search to see if I can find anything.

@petersaints
Copy link
Author

petersaints commented Sep 24, 2019

@1224hinduja
Also, if it helps, I think that this snippet was taken from here: https://github.com/takahirom/webview-in-coordinatorlayout
More specifically the activity_scrolling.xml file in this folder: https://github.com/takahirom/webview-in-coordinatorlayout/tree/master/app/src/main/res/layout

And as you can see they have a GIF that shows the effect: https://cloud.githubusercontent.com/assets/1386930/13979570/b7235d0a-f11c-11e5-80e0-5ab6faa683e2.gif

@VelupulaHinduja
Copy link

Output means the screenshot of the emulator after running this piece of code...
Any way Thank you,I understood it.
Can you tell me how to get the fragment as a tabbed activity in a tabbed activity ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment