Skip to content

Instantly share code, notes, and snippets.

@dadino
dadino / activity_main.xml
Last active December 26, 2020 19:01
A CoordinatorLayout layout, with a Google Map that collapse itself. A TabLayout (inside the CollapsingToolbarLayout) provides navigation for the ViewPager, that sits just below the AppBarLayout. The FloatingActionButton is used to go to the next page in the ViewPager.
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
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.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- google's material design colours from
http://www.google.com/design/spec/style/color.html#color-ui-color-palette -->
<!--reds-->
<color name="md_red_50">#fffde0dc</color>
<color name="md_red_100">#fff9bdbb</color>
<color name="md_red_200">#fff69988</color>
<color name="md_red_300">#fff36c60</color>
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
public class FragmentUtils {
public static void addFragmentsInActivity(Activity act,
int containerId, Fragment fragment, String tag) {
FragmentManager fm = act.getFragmentManager();