diff --git a/MaterialSample/app/src/main/AndroidManifest.xml b/MaterialSample/app/src/main/AndroidManifest.xml
index 3bd1aff..5a93c63 100644
--- a/MaterialSample/app/src/main/AndroidManifest.xml
+++ b/MaterialSample/app/src/main/AndroidManifest.xml
@@ -1,15 +1,15 @@
+ package="com.suleiman.material">
+ android:theme="@style/MyTheme">
+ android:label="@string/app_name">
@@ -51,8 +51,11 @@
android:label="@string/title_activity_reveal_animation" />
-
+ android:label="@string/title_activity_gmail_style" />
+
diff --git a/MaterialSample/app/src/main/java/com/suleiman/material/activities/TabAnimationActivity.java b/MaterialSample/app/src/main/java/com/suleiman/material/activities/TabAnimationActivity.java
index ec879f6..48de41d 100644
--- a/MaterialSample/app/src/main/java/com/suleiman/material/activities/TabAnimationActivity.java
+++ b/MaterialSample/app/src/main/java/com/suleiman/material/activities/TabAnimationActivity.java
@@ -1,6 +1,7 @@
package com.suleiman.material.activities;
import android.annotation.SuppressLint;
+import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
@@ -90,7 +91,7 @@ private void setupViewPager(ViewPager viewPager) {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.menu_main, menu);
+ getMenuInflater().inflate(R.menu.menu_tab_switch, menu);
return true;
}
@@ -100,7 +101,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
case android.R.id.home:
finish();
return true;
- case R.id.action_settings:
+ case R.id.action_switch:
+ Intent intent = new Intent(TabAnimationActivity.this, TabsHeaderActivity.class);
+ startActivity(intent);
return true;
}
return super.onOptionsItemSelected(item);
diff --git a/MaterialSample/app/src/main/java/com/suleiman/material/activities/TabsHeaderActivity.java b/MaterialSample/app/src/main/java/com/suleiman/material/activities/TabsHeaderActivity.java
new file mode 100644
index 0000000..cbdaa53
--- /dev/null
+++ b/MaterialSample/app/src/main/java/com/suleiman/material/activities/TabsHeaderActivity.java
@@ -0,0 +1,203 @@
+package com.suleiman.material.activities;
+
+import android.annotation.SuppressLint;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.os.Bundle;
+import android.support.design.widget.CollapsingToolbarLayout;
+import android.support.design.widget.TabLayout;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentPagerAdapter;
+import android.support.v4.view.ViewPager;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.graphics.Palette;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.support.v7.widget.Toolbar;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
+import android.widget.Toast;
+
+import com.suleiman.material.R;
+import com.suleiman.material.adapter.SimpleRecyclerAdapter;
+import com.suleiman.material.model.VersionModel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TabsHeaderActivity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_tabs_header);
+
+ final Toolbar toolbar = (Toolbar) findViewById(R.id.htab_toolbar);
+ setSupportActionBar(toolbar);
+ getSupportActionBar().setTitle("Parallax Tabs");
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+
+ final ViewPager viewPager = (ViewPager) findViewById(R.id.htab_viewpager);
+ setupViewPager(viewPager);
+
+
+ TabLayout tabLayout = (TabLayout) findViewById(R.id.htab_tabs);
+ tabLayout.setupWithViewPager(viewPager);
+
+ final CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.htab_collapse_toolbar);
+ collapsingToolbarLayout.setTitleEnabled(false);
+
+ ImageView header = (ImageView) findViewById(R.id.header);
+
+ Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
+ R.drawable.header);
+
+ Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() {
+ @SuppressWarnings("ResourceType")
+ @Override
+ public void onGenerated(Palette palette) {
+
+ int vibrantColor = palette.getVibrantColor(R.color.primary_500);
+ int vibrantDarkColor = palette.getDarkVibrantColor(R.color.primary_700);
+ collapsingToolbarLayout.setContentScrimColor(vibrantColor);
+ collapsingToolbarLayout.setStatusBarScrimColor(vibrantDarkColor);
+ }
+ });
+
+ tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
+ @Override
+ public void onTabSelected(TabLayout.Tab tab) {
+
+ viewPager.setCurrentItem(tab.getPosition());
+
+ switch (tab.getPosition()) {
+ case 0:
+ showToast("One");
+ break;
+ case 1:
+ showToast("Two");
+
+ break;
+ case 2:
+ showToast("Three");
+
+ break;
+ }
+ }
+
+ @Override
+ public void onTabUnselected(TabLayout.Tab tab) {
+
+ }
+
+ @Override
+ public void onTabReselected(TabLayout.Tab tab) {
+
+ }
+ });
+ }
+
+
+ void showToast(String msg) {
+ Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
+ }
+
+ private void setupViewPager(ViewPager viewPager) {
+ ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
+ adapter.addFrag(new DummyFragment(getResources().getColor(R.color.accent_material_light)), "CAT");
+ adapter.addFrag(new DummyFragment(getResources().getColor(R.color.ripple_material_light)), "DOG");
+ adapter.addFrag(new DummyFragment(getResources().getColor(R.color.button_material_dark)), "MOUSE");
+ viewPager.setAdapter(adapter);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.menu_main, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ finish();
+ return true;
+ case R.id.action_settings:
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ static class ViewPagerAdapter extends FragmentPagerAdapter {
+ private final List mFragmentList = new ArrayList<>();
+ private final List mFragmentTitleList = new ArrayList<>();
+
+ public ViewPagerAdapter(FragmentManager manager) {
+ super(manager);
+ }
+
+ @Override
+ public Fragment getItem(int position) {
+ return mFragmentList.get(position);
+ }
+
+ @Override
+ public int getCount() {
+ return mFragmentList.size();
+ }
+
+ public void addFrag(Fragment fragment, String title) {
+ mFragmentList.add(fragment);
+ mFragmentTitleList.add(title);
+ }
+
+ @Override
+ public CharSequence getPageTitle(int position) {
+ return mFragmentTitleList.get(position);
+ }
+ }
+
+ public static class DummyFragment extends Fragment {
+ int color;
+ SimpleRecyclerAdapter adapter;
+
+ public DummyFragment() {
+ }
+
+ @SuppressLint("ValidFragment")
+ public DummyFragment(int color) {
+ this.color = color;
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.dummy_fragment, container, false);
+
+ final FrameLayout frameLayout = (FrameLayout) view.findViewById(R.id.dummyfrag_bg);
+ frameLayout.setBackgroundColor(color);
+
+ RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.dummyfrag_scrollableview);
+
+ LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity().getBaseContext());
+ recyclerView.setLayoutManager(linearLayoutManager);
+ recyclerView.setHasFixedSize(true);
+
+ List list = new ArrayList();
+ for (int i = 0; i < VersionModel.data.length; i++) {
+ list.add(VersionModel.data[i]);
+ }
+
+ adapter = new SimpleRecyclerAdapter(list);
+ recyclerView.setAdapter(adapter);
+
+ return view;
+ }
+ }
+}
diff --git a/MaterialSample/app/src/main/java/com/suleiman/material/activities/ToolbarOverlayActivity.java b/MaterialSample/app/src/main/java/com/suleiman/material/activities/ToolbarOverlayActivity.java
index 3fb572b..8594154 100644
--- a/MaterialSample/app/src/main/java/com/suleiman/material/activities/ToolbarOverlayActivity.java
+++ b/MaterialSample/app/src/main/java/com/suleiman/material/activities/ToolbarOverlayActivity.java
@@ -32,7 +32,7 @@ protected void onCreate(Bundle savedInstanceState) {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
- getWindow().setStatusBarColor(getResources().getColor(R.color.black_trans80));
+ getWindow().setStatusBarColor(getResources().getColor(R.color.black_trans80,null));
statusBarHeight = Utils.getStatusBarHeight(this);
isStatusBarTransparent = true;
diff --git a/MaterialSample/app/src/main/res/layout/activity_tabs_header.xml b/MaterialSample/app/src/main/res/layout/activity_tabs_header.xml
new file mode 100644
index 0000000..7a7f369
--- /dev/null
+++ b/MaterialSample/app/src/main/res/layout/activity_tabs_header.xml
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/MaterialSample/app/src/main/res/menu/menu_main.xml b/MaterialSample/app/src/main/res/menu/menu_main.xml
index 77fec3c..22293eb 100644
--- a/MaterialSample/app/src/main/res/menu/menu_main.xml
+++ b/MaterialSample/app/src/main/res/menu/menu_main.xml
@@ -1,7 +1,10 @@
diff --git a/MaterialSample/app/src/main/res/menu/menu_tab_switch.xml b/MaterialSample/app/src/main/res/menu/menu_tab_switch.xml
new file mode 100644
index 0000000..3271d34
--- /dev/null
+++ b/MaterialSample/app/src/main/res/menu/menu_tab_switch.xml
@@ -0,0 +1,10 @@
+
diff --git a/MaterialSample/app/src/main/res/values/strings.xml b/MaterialSample/app/src/main/res/values/strings.xml
index 4f4bba7..87ca815 100644
--- a/MaterialSample/app/src/main/res/values/strings.xml
+++ b/MaterialSample/app/src/main/res/values/strings.xml
@@ -22,4 +22,5 @@
Reveal Animation
LaunchScreenActivity
Gmail List
+ Header Tabs
diff --git a/MaterialSample/app/src/main/res/values/styles.xml b/MaterialSample/app/src/main/res/values/styles.xml
index b8fde89..6361fa7 100644
--- a/MaterialSample/app/src/main/res/values/styles.xml
+++ b/MaterialSample/app/src/main/res/values/styles.xml
@@ -25,6 +25,10 @@
- true
+
+