diff --git a/README.md b/README.md index 045b78c..d1acc53 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,24 @@ ### 轻量级的底部导航栏 +在原项目[PagerBottomTabStrip](https://github.com/tyzlmjj/PagerBottomTabStrip) 基础上 +增加了 getItem 方法,能设置对应 position 的 tab 属性 + ### 实现效果图 -|![horizontal](/img/demo.png "horizontal")|![vertical](/img/demo8.png "vertical")| +|![horizontal](/intro_img/demo.png "horizontal")|![vertical](/intro_img/demo8.png "vertical")| |---|---| -|![Material 1](/img/demo1.gif "Material 1")|![Material 2](/img/demo2.gif "Material 2")| -|![Material 3](/img/demo3.gif "Material 3")|![Material 4](/img/demo4.gif "Material 4")| +|![Material 1](/intro_img/demo1.gif "Material 1")|![Material 2](/intro_img/demo2.gif "Material 2")| +|![Material 3](/intro_img/demo3.gif "Material 3")|![Material 4](/intro_img/demo4.gif "Material 4")| ### 自定义扩展例子 |Library中已经实现的一个最普通的效果| |---| -|![PagerBottomTabStrip](/img/demo5.gif "PagerBottomTabStrip")| +|![PagerBottomTabStrip](/intro_img/demo5.gif "PagerBottomTabStrip")| |Demo中的例子|| |---|---| -|![PagerBottomTabStrip](/img/demo7.png "PagerBottomTabStrip")|![PagerBottomTabStrip](/img/demo6.png "PagerBottomTabStrip")| +|![PagerBottomTabStrip](/intro_img/demo7.png "PagerBottomTabStrip")|![PagerBottomTabStrip](/intro_img/demo6.png "PagerBottomTabStrip")| ### 使用 @@ -73,6 +76,6 @@ xml文件 打开app的module中的build.gradle,在dependencies{}中,添加依赖,如下: dependencies { - compile 'com.github.wenchaosong:bottomBar:3.0.3' + compile 'com.github.wenchaosong:bottomBar:3.0.5' } diff --git a/demo/build.gradle b/demo/build.gradle index edd7bb1..bffbffb 100644 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -22,4 +22,5 @@ android { dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile project(':library') + compile 'com.android.support:design:25.3.1' } diff --git a/demo/src/main/AndroidManifest.xml b/demo/src/main/AndroidManifest.xml index 0d8fe8c..4baad5a 100644 --- a/demo/src/main/AndroidManifest.xml +++ b/demo/src/main/AndroidManifest.xml @@ -1,21 +1,42 @@ + package="com.simple"> + - + - + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/demo/src/main/java/com/simple/BehaviorActivity.java b/demo/src/main/java/com/simple/BehaviorActivity.java new file mode 100644 index 0000000..a18c965 --- /dev/null +++ b/demo/src/main/java/com/simple/BehaviorActivity.java @@ -0,0 +1,109 @@ +package com.simple; + +import android.os.Bundle; +import android.support.annotation.Nullable; +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.widget.DividerItemDecoration; +import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.Toolbar; +import android.util.TypedValue; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import com.bottom.NavigationController; +import com.bottom.PageNavigationView; + +public class BehaviorActivity extends AppCompatActivity { + + NavigationController mNavigationController; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_behavior); + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + PageNavigationView pageBottomTabLayout = (PageNavigationView) findViewById(R.id.tab); + + mNavigationController = pageBottomTabLayout.material() + .addItem(R.drawable.ic_restore_teal_24dp, "Recents") + .addItem(R.drawable.ic_favorite_teal_24dp, "Favorites") + .addItem(R.drawable.ic_nearby_teal_24dp, "Nearby") + .build(); + + ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager); + viewPager.setAdapter(new TestViewPagerAdapter(getSupportFragmentManager())); + + mNavigationController.setupWithViewPager(viewPager); + } + + //下面几个类都是为了测试写的 + private class TestViewPagerAdapter extends FragmentPagerAdapter { + + public TestViewPagerAdapter(FragmentManager fm) { + super(fm); + } + + @Override + public Fragment getItem(int position) { + return new TestFragment(); + } + + @Override + public int getCount() { + return mNavigationController.getItemCount(); + } + } + + public static class TestFragment extends Fragment { + + @Nullable + @Override + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + return inflater.inflate(R.layout.recyclerview, container, false); + } + + @Override + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView); + recyclerView.setAdapter(new TestAdapter()); + recyclerView.addItemDecoration(new DividerItemDecoration(view.getContext(), DividerItemDecoration.VERTICAL)); + } + } + + private static class TestAdapter extends RecyclerView.Adapter { + + @Override + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + int padding = (int) TypedValue.applyDimension( + TypedValue.COMPLEX_UNIT_DIP, 16, parent.getResources().getDisplayMetrics()); + TextView textView = new TextView(parent.getContext()); + textView.setPadding(padding, padding, padding, padding); + textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); + + return new RecyclerView.ViewHolder(textView) { + }; + } + + @Override + public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { + + if (holder.itemView instanceof TextView) { + ((TextView) holder.itemView).setText(String.valueOf(position)); + } + } + + @Override + public int getItemCount() { + return 100; + } + } +} diff --git a/demo/src/main/java/com/simple/Custom2Activity.java b/demo/src/main/java/com/simple/Custom2Activity.java new file mode 100644 index 0000000..f609791 --- /dev/null +++ b/demo/src/main/java/com/simple/Custom2Activity.java @@ -0,0 +1,49 @@ +package com.simple; + +import android.os.Bundle; +import android.support.v4.view.ViewPager; +import android.support.v7.app.AppCompatActivity; + +import com.bottom.NavigationController; +import com.bottom.PageNavigationView; +import com.bottom.item.BaseTabItem; +import com.simple.custom.OnlyIconItemView; +import com.simple.custom.TestRepeatTab; +import com.simple.other.MyViewPagerAdapter; + +public class Custom2Activity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.layout_horizontal); + + PageNavigationView tab = (PageNavigationView) findViewById(R.id.tab); + + NavigationController navigationController = tab.custom() + .addItem(newItem_test(R.drawable.ic_restore_gray_24dp, R.drawable.ic_restore_teal_24dp)) + .addItem(newItem(R.drawable.ic_favorite_gray_24dp, R.drawable.ic_favorite_teal_24dp)) + .addItem(newItem(R.drawable.ic_nearby_gray_24dp, R.drawable.ic_nearby_teal_24dp)) + .build(); + + ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager); + viewPager.setAdapter(new MyViewPagerAdapter(getSupportFragmentManager(), navigationController.getItemCount())); + + //自动适配ViewPager页面切换 + navigationController.setupWithViewPager(viewPager); + } + + //创建一个Item + private BaseTabItem newItem(int drawable, int checkedDrawable) { + OnlyIconItemView onlyIconItemView = new OnlyIconItemView(this); + onlyIconItemView.initialize(drawable, checkedDrawable); + return onlyIconItemView; + } + + //创建一个Item(测试重复点击的方法) + private BaseTabItem newItem_test(int drawable, int checkedDrawable) { + TestRepeatTab testRepeatTab = new TestRepeatTab(this); + testRepeatTab.initialize(drawable, checkedDrawable); + return testRepeatTab; + } +} diff --git a/demo/src/main/java/com/simple/CustomActivity.java b/demo/src/main/java/com/simple/CustomActivity.java new file mode 100644 index 0000000..b484bd8 --- /dev/null +++ b/demo/src/main/java/com/simple/CustomActivity.java @@ -0,0 +1,50 @@ +package com.simple; + +import android.graphics.Color; +import android.os.Bundle; +import android.support.v4.view.ViewPager; +import android.support.v7.app.AppCompatActivity; + +import com.bottom.NavigationController; +import com.bottom.PageNavigationView; +import com.bottom.item.BaseTabItem; +import com.bottom.item.NormalItemView; +import com.simple.other.MyViewPagerAdapter; + +public class CustomActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.layout_horizontal); + + PageNavigationView tab = (PageNavigationView) findViewById(R.id.tab); + + NavigationController navigationController = tab.custom() + .addItem(newItem(R.drawable.ic_restore_gray_24dp, R.drawable.ic_restore_teal_24dp, "Recents")) + .addItem(newItem(R.drawable.ic_favorite_gray_24dp, R.drawable.ic_favorite_teal_24dp, "Favorites")) + .addItem(newItem(R.drawable.ic_nearby_gray_24dp, R.drawable.ic_nearby_teal_24dp, "Nearby")) + .build(); + + ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager); + viewPager.setAdapter(new MyViewPagerAdapter(getSupportFragmentManager(), navigationController.getItemCount())); + + //自动适配ViewPager页面切换 + navigationController.setupWithViewPager(viewPager); + + //设置消息数 + navigationController.setMessageNumber(1, 8); + + //设置显示小圆点 + navigationController.setHasMessage(0, true); + } + + //创建一个Item + private BaseTabItem newItem(int drawable, int checkedDrawable, String text) { + NormalItemView normalItemView = new NormalItemView(this); + normalItemView.initialize(drawable, checkedDrawable, text); + normalItemView.setTextDefaultColor(Color.GRAY); + normalItemView.setTextCheckedColor(0xFF009688); + return normalItemView; + } +} diff --git a/demo/src/main/java/com/simple/HideActivity.java b/demo/src/main/java/com/simple/HideActivity.java new file mode 100644 index 0000000..a38aa7b --- /dev/null +++ b/demo/src/main/java/com/simple/HideActivity.java @@ -0,0 +1,127 @@ +package com.simple; + +import android.os.Bundle; +import android.support.annotation.Nullable; +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.widget.DividerItemDecoration; +import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.Toolbar; +import android.util.TypedValue; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import com.bottom.NavigationController; +import com.bottom.PageNavigationView; + +public class HideActivity extends AppCompatActivity { + + static NavigationController mNavigationController; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_hide); + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + PageNavigationView pageBottomTabLayout = (PageNavigationView) findViewById(R.id.tab); + + mNavigationController = pageBottomTabLayout.material() + .addItem(R.drawable.ic_restore_teal_24dp, "Recents") + .addItem(R.drawable.ic_favorite_teal_24dp, "Favorites") + .addItem(R.drawable.ic_nearby_teal_24dp, "Nearby") + .build(); + + ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager); + viewPager.setAdapter(new TestViewPagerAdapter(getSupportFragmentManager())); + + mNavigationController.setupWithViewPager(viewPager); + } + + /** + * 监听列表的滑动来控制底部导航栏的显示与隐藏 + */ + private static class ListScrollListener extends RecyclerView.OnScrollListener { + + @Override + public void onScrolled(RecyclerView recyclerView, int dx, int dy) { + super.onScrolled(recyclerView, dx, dy); + if (dy > 8) {//列表向上滑动 + mNavigationController.hideBottomLayout(); + } else if (dy < -8) {//列表向下滑动 + mNavigationController.showBottomLayout(); + } + } + } + + //下面几个类都是为了测试写的 + + private class TestViewPagerAdapter extends FragmentPagerAdapter { + + TestViewPagerAdapter(FragmentManager fm) { + super(fm); + } + + @Override + public Fragment getItem(int position) { + return new TestFragment(); + } + + @Override + public int getCount() { + return mNavigationController.getItemCount(); + } + } + + public static class TestFragment extends Fragment { + + @Nullable + @Override + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + return inflater.inflate(R.layout.recyclerview, container, false); + } + + @Override + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView); + recyclerView.setAdapter(new TestAdapter()); + recyclerView.addItemDecoration(new DividerItemDecoration(view.getContext(), DividerItemDecoration.VERTICAL)); + recyclerView.addOnScrollListener(new ListScrollListener()); + } + } + + private static class TestAdapter extends RecyclerView.Adapter { + + @Override + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + int padding = (int) TypedValue.applyDimension( + TypedValue.COMPLEX_UNIT_DIP, 16, parent.getResources().getDisplayMetrics()); + TextView textView = new TextView(parent.getContext()); + textView.setPadding(padding, padding, padding, padding); + textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); + + return new RecyclerView.ViewHolder(textView) { + }; + } + + @Override + public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { + + if (holder.itemView instanceof TextView) { + ((TextView) holder.itemView).setText(String.valueOf(position)); + } + } + + @Override + public int getItemCount() { + return 100; + } + } +} diff --git a/demo/src/main/java/com/simple/MainActivity.java b/demo/src/main/java/com/simple/MainActivity.java index 2ee253f..ce9a341 100644 --- a/demo/src/main/java/com/simple/MainActivity.java +++ b/demo/src/main/java/com/simple/MainActivity.java @@ -1,101 +1,48 @@ package com.simple; +import android.content.Intent; import android.os.Bundle; -import android.os.Handler; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentActivity; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentStatePagerAdapter; -import android.support.v4.view.ViewPager; +import android.support.annotation.Nullable; +import android.support.v7.app.AppCompatActivity; import android.view.View; -import android.view.animation.Animation; -import android.view.animation.RotateAnimation; -import android.widget.ImageView; -import com.bottom.NavigationController; -import com.bottom.PageNavigationView; -import com.bottom.item.BaseTabItem; - -import java.util.ArrayList; -import java.util.List; - -public class MainActivity extends FragmentActivity { - - private ViewPager mVpContent; - private List mFragmentList = new ArrayList<>(); +public class MainActivity extends AppCompatActivity { @Override - protected void onCreate(Bundle savedInstanceState) { + protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - - mVpContent = (ViewPager) findViewById(R.id.vp_content); - - initData(); - - mVpContent.setAdapter(new MyAdapter(getSupportFragmentManager())); - - PageNavigationView bottomTabLayout = (PageNavigationView) findViewById(R.id.tab); - PageNavigationView.CustomBuilder custom = bottomTabLayout.custom(); - NavigationController build = custom - .addItem(newItem(android.R.drawable.ic_menu_camera, android.R.drawable.ic_menu_camera, "相机")) - .addItem(newItem(android.R.drawable.ic_menu_compass, android.R.drawable.ic_menu_compass, "位置")) - .addItem(newItem(android.R.drawable.ic_menu_search, android.R.drawable.ic_menu_search, "搜索")) - .addItem(newItem(android.R.drawable.ic_menu_help, android.R.drawable.ic_menu_help, "帮助")) - .build(); - build.setupWithViewPager(mVpContent); } - private void initData() { - - TabFragment homeFragment = new TabFragment(); - Bundle bundle1 = new Bundle(); - bundle1.putString(TabFragment.CONTENT, "首页"); - homeFragment.setArguments(bundle1); - mFragmentList.add(homeFragment); - - TabFragment videoFragment = new TabFragment(); - Bundle bundle2 = new Bundle(); - bundle2.putString(TabFragment.CONTENT, "视频"); - videoFragment.setArguments(bundle2); - mFragmentList.add(videoFragment); + public void toMaterialdesign(View view) { + startActivity(new Intent(this, MaterialDesignActivity.class)); + } - TabFragment microFragment = new TabFragment(); - Bundle bundle3 = new Bundle(); - bundle3.putString(TabFragment.CONTENT, "微头条"); - microFragment.setArguments(bundle3); - mFragmentList.add(microFragment); + public void toCustom(View view) { + startActivity(new Intent(this, CustomActivity.class)); + } - TabFragment meFragment = new TabFragment(); - Bundle bundle4 = new Bundle(); - bundle4.putString(TabFragment.CONTENT, "我的"); - meFragment.setArguments(bundle4); - mFragmentList.add(meFragment); + public void toCustom2(View view) { + startActivity(new Intent(this, Custom2Activity.class)); } - //创建一个Item - private BaseTabItem newItem(int drawable, int checkedDrawable, String text) { - BottomItemTab normalItemView = new BottomItemTab(this); - normalItemView.initialize(drawable, checkedDrawable, text); - normalItemView.setTextDefaultColor(getResources().getColor(R.color.tab_gb)); - normalItemView.setTextCheckedColor(getResources().getColor(R.color.selector_grey)); - return normalItemView; + public void toBehavior(View view) { + startActivity(new Intent(this, BehaviorActivity.class)); } - class MyAdapter extends FragmentStatePagerAdapter { + public void toHide(View view) { + startActivity(new Intent(this, HideActivity.class)); + } - public MyAdapter(FragmentManager fm) { - super(fm); - } + public void toSpecial(View view) { + startActivity(new Intent(this, SpecialActivity.class)); + } - @Override - public Fragment getItem(int position) { - return mFragmentList.get(position); - } + public void toVertical(View view) { + startActivity(new Intent(this, VerticalActivity.class)); + } - @Override - public int getCount() { - return mFragmentList.size(); - } + public void toCsutomVertical(View view) { + startActivity(new Intent(this, VerticalCustomActivity.class)); } } diff --git a/demo/src/main/java/com/simple/MaterialDesignActivity.java b/demo/src/main/java/com/simple/MaterialDesignActivity.java new file mode 100644 index 0000000..855042d --- /dev/null +++ b/demo/src/main/java/com/simple/MaterialDesignActivity.java @@ -0,0 +1,60 @@ +package com.simple; + +import android.os.Bundle; +import android.support.v4.view.ViewPager; +import android.support.v7.app.AppCompatActivity; +import android.util.Log; + +import com.bottom.MaterialMode; +import com.bottom.NavigationController; +import com.bottom.PageNavigationView; +import com.bottom.listener.OnTabItemSelectedListener; +import com.simple.other.MyViewPagerAdapter; + +public class MaterialDesignActivity extends AppCompatActivity { + + int[] testColors = {0xFF455A64, 0xFF00796B, 0xFF795548, 0xFF5B4947, 0xFFF57C00}; + // int[] testColors = {0xFF009688, 0xFF009688, 0xFF009688, 0xFF009688, 0xFF009688}; + + NavigationController mNavigationController; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.layout_horizontal); + + PageNavigationView pageBottomTabLayout = (PageNavigationView) findViewById(R.id.tab); + + mNavigationController = pageBottomTabLayout.material() + .addItem(R.drawable.ic_ondemand_video_black_24dp, "Movies & TV", testColors[0]) + .addItem(R.drawable.ic_audiotrack_black_24dp, "Music", testColors[1]) + .addItem(R.drawable.ic_book_black_24dp, "Books", testColors[2]) + .addItem(R.drawable.ic_news_black_24dp, "Newsstand", testColors[3]) + .setDefaultColor(0x89FFFFFF)//未选中状态的颜色 + .setMode(MaterialMode.CHANGE_BACKGROUND_COLOR | MaterialMode.HIDE_TEXT)//这里可以设置样式模式,总共可以组合出4种效果 + .build(); + + ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager); + viewPager.setAdapter(new MyViewPagerAdapter(getSupportFragmentManager(), mNavigationController.getItemCount())); + + //自动适配ViewPager页面切换 + mNavigationController.setupWithViewPager(viewPager); + + //也可以设置Item选中事件的监听 + mNavigationController.addTabItemSelectedListener(new OnTabItemSelectedListener() { + @Override + public void onSelected(int index, int old) { + Log.i("asd", "selected: " + index + " old: " + old); + } + + @Override + public void onRepeat(int index) { + Log.i("asd", "onRepeat selected: " + index); + } + }); + + //设置消息圆点 + // mNavigationController.setMessageNumber(0,12); + // mNavigationController.setHasMessage(3,true); + } +} diff --git a/demo/src/main/java/com/simple/SpecialActivity.java b/demo/src/main/java/com/simple/SpecialActivity.java new file mode 100644 index 0000000..c6333c2 --- /dev/null +++ b/demo/src/main/java/com/simple/SpecialActivity.java @@ -0,0 +1,64 @@ +package com.simple; + +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v4.view.ViewPager; +import android.support.v7.app.AppCompatActivity; + +import com.bottom.NavigationController; +import com.bottom.PageNavigationView; +import com.bottom.item.BaseTabItem; +import com.simple.custom.SpecialTab; +import com.simple.custom.SpecialTabRound; +import com.simple.other.MyViewPagerAdapter; + +/** + * Created by mjj on 2017/6/25 + */ +public class SpecialActivity extends AppCompatActivity { + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_special); + + PageNavigationView tab = (PageNavigationView) findViewById(R.id.tab); + + NavigationController navigationController = tab.custom() + .addItem(newItem(R.drawable.ic_restore_gray_24dp, R.drawable.ic_restore_teal_24dp, "Recents")) + .addItem(newItem(R.drawable.ic_favorite_gray_24dp, R.drawable.ic_favorite_teal_24dp, "Favorites")) + .addItem(newRoundItem(R.drawable.ic_nearby_gray_24dp, R.drawable.ic_nearby_teal_24dp, "Nearby")) + .addItem(newItem(R.drawable.ic_favorite_gray_24dp, R.drawable.ic_favorite_teal_24dp, "Favorites")) + .addItem(newItem(R.drawable.ic_restore_gray_24dp, R.drawable.ic_restore_teal_24dp, "Recents")) + .build(); + + ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager); + viewPager.setAdapter(new MyViewPagerAdapter(getSupportFragmentManager(), navigationController.getItemCount())); + + //自动适配ViewPager页面切换 + navigationController.setupWithViewPager(viewPager); + } + + /** + * 正常tab + */ + private BaseTabItem newItem(int drawable, int checkedDrawable, String text) { + SpecialTab mainTab = new SpecialTab(this); + mainTab.initialize(drawable, checkedDrawable, text); + mainTab.setTextDefaultColor(0xFF888888); + mainTab.setTextCheckedColor(0xFF009688); + return mainTab; + } + + /** + * 圆形tab + */ + private BaseTabItem newRoundItem(int drawable, int checkedDrawable, String text) { + SpecialTabRound mainTab = new SpecialTabRound(this); + mainTab.initialize(drawable, checkedDrawable, text); + mainTab.setTextDefaultColor(0xFF888888); + mainTab.setTextCheckedColor(0xFF009688); + return mainTab; + } + +} diff --git a/demo/src/main/java/com/simple/TabFragment.java b/demo/src/main/java/com/simple/TabFragment.java deleted file mode 100644 index dcade34..0000000 --- a/demo/src/main/java/com/simple/TabFragment.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.simple; - -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -public class TabFragment extends Fragment { - - public static final String CONTENT = "content"; - private TextView mTextView; - - @Nullable - @Override - public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle bundle) { - mTextView = new TextView(getActivity()); - mTextView.setGravity(Gravity.CENTER); - String content = getArguments().getString(CONTENT); - mTextView.setText(content); - return mTextView; - } - -} diff --git a/demo/src/main/java/com/simple/VerticalActivity.java b/demo/src/main/java/com/simple/VerticalActivity.java new file mode 100644 index 0000000..949b8fa --- /dev/null +++ b/demo/src/main/java/com/simple/VerticalActivity.java @@ -0,0 +1,60 @@ +package com.simple; + +import android.os.Bundle; +import android.support.v4.view.ViewPager; +import android.support.v7.app.AppCompatActivity; +import android.util.Log; + +import com.bottom.NavigationController; +import com.bottom.PageNavigationView; +import com.bottom.listener.OnTabItemSelectedListener; +import com.simple.other.MyViewPagerAdapter; + +/** + * Created by mjj on 2017/8/3 + */ +public class VerticalActivity extends AppCompatActivity { + + int[] testColors = {0xFF455A64, 0xFF00796B, 0xFF795548, 0xFF5B4947, 0xFFF57C00}; + + NavigationController mNavigationController; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.layout_vertical); + + PageNavigationView pageBottomTabLayout = (PageNavigationView) findViewById(R.id.tab); + + mNavigationController = pageBottomTabLayout.material() + .addItem(R.drawable.ic_ondemand_video_black_24dp, "Movies & TV", testColors[0]) + .addItem(R.drawable.ic_audiotrack_black_24dp, "Music", testColors[1]) + .addItem(R.drawable.ic_book_black_24dp, "Books", testColors[2]) + .addItem(R.drawable.ic_news_black_24dp, "Newsstand", testColors[3]) + .enableVerticalLayout()//使用垂直布局 + .build(); + + ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager); + viewPager.setAdapter(new MyViewPagerAdapter(getSupportFragmentManager(), mNavigationController.getItemCount())); + + //自动适配ViewPager页面切换 + mNavigationController.setupWithViewPager(viewPager); + + //也可以设置Item选中事件的监听 + mNavigationController.addTabItemSelectedListener(new OnTabItemSelectedListener() { + @Override + public void onSelected(int index, int old) { + Log.i("asd", "selected: " + index + " old: " + old); + } + + @Override + public void onRepeat(int index) { + Log.i("asd", "onRepeat selected: " + index); + } + }); + + //设置消息圆点 + mNavigationController.setMessageNumber(0, 8); + mNavigationController.setHasMessage(3, true); + } +} diff --git a/demo/src/main/java/com/simple/VerticalCustomActivity.java b/demo/src/main/java/com/simple/VerticalCustomActivity.java new file mode 100644 index 0000000..5972460 --- /dev/null +++ b/demo/src/main/java/com/simple/VerticalCustomActivity.java @@ -0,0 +1,51 @@ +package com.simple; + +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v4.view.ViewPager; +import android.support.v7.app.AppCompatActivity; + +import com.bottom.NavigationController; +import com.bottom.PageNavigationView; +import com.simple.custom.OnlyTextTab; +import com.simple.other.MyViewPagerAdapter; + +/** + * Created by mjj on 2017/9/26 + */ +public class VerticalCustomActivity extends AppCompatActivity { + + private NavigationController mNavigationController; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_vertical_custom); + + PageNavigationView pageNavigationView = (PageNavigationView) findViewById(R.id.tab); + mNavigationController = pageNavigationView.custom() + .addItem(new OnlyTextTab(this, "A")) + .addItem(new OnlyTextTab(this, "B")) + .addItem(new OnlyTextTab(this, "C")) + .addItem(new OnlyTextTab(this, "D")) + .addItem(new OnlyTextTab(this, "E")) + .addItem(new OnlyTextTab(this, "F")) + .addItem(new OnlyTextTab(this, "G")) + .addItem(new OnlyTextTab(this, "H")) + .addItem(new OnlyTextTab(this, "I")) + .addItem(new OnlyTextTab(this, "J")) + .addItem(new OnlyTextTab(this, "K")) + .addItem(new OnlyTextTab(this, "L")) + .addItem(new OnlyTextTab(this, "M")) + .addItem(new OnlyTextTab(this, "N")) + .addItem(new OnlyTextTab(this, "O")) + .enableVerticalLayout() + .build(); + + ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager); + viewPager.setAdapter(new MyViewPagerAdapter(getSupportFragmentManager(), mNavigationController.getItemCount())); + + //自动适配ViewPager页面切换 + mNavigationController.setupWithViewPager(viewPager); + } +} diff --git a/demo/src/main/java/com/simple/behavior/BottomViewBehavior.java b/demo/src/main/java/com/simple/behavior/BottomViewBehavior.java new file mode 100644 index 0000000..85658f1 --- /dev/null +++ b/demo/src/main/java/com/simple/behavior/BottomViewBehavior.java @@ -0,0 +1,38 @@ +package com.simple.behavior; + +import android.content.Context; +import android.support.design.widget.AppBarLayout; +import android.support.design.widget.CoordinatorLayout; +import android.support.v4.view.ViewCompat; +import android.util.AttributeSet; +import android.view.View; + +public class BottomViewBehavior extends CoordinatorLayout.Behavior { + + public BottomViewBehavior() { + } + + public BottomViewBehavior(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + public boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection) { + + ((CoordinatorLayout.LayoutParams) child.getLayoutParams()).topMargin = parent.getMeasuredHeight() - child.getMeasuredHeight(); + return super.onLayoutChild(parent, child, layoutDirection); + } + + @Override + public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) { + return dependency instanceof AppBarLayout; + } + + @Override + public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) { + + int top = ((AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) dependency.getLayoutParams()).getBehavior()).getTopAndBottomOffset(); + ViewCompat.setTranslationY(child, -top); + return false; + } +} diff --git a/demo/src/main/java/com/simple/custom/OnlyIconItemView.java b/demo/src/main/java/com/simple/custom/OnlyIconItemView.java new file mode 100644 index 0000000..3929af9 --- /dev/null +++ b/demo/src/main/java/com/simple/custom/OnlyIconItemView.java @@ -0,0 +1,62 @@ +package com.simple.custom; + +import android.content.Context; +import android.support.annotation.DrawableRes; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.widget.ImageView; + +import com.bottom.item.BaseTabItem; +import com.simple.R; + +/** + * 自定义一个只有图标的Item + */ +public class OnlyIconItemView extends BaseTabItem { + + private ImageView mIcon; + + private int mDefaultDrawable; + private int mCheckedDrawable; + + public OnlyIconItemView(Context context) { + this(context, null); + } + + public OnlyIconItemView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public OnlyIconItemView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + + LayoutInflater.from(context).inflate(R.layout.item_only_icon, this, true); + + mIcon = (ImageView) findViewById(R.id.icon); + } + + public void initialize(@DrawableRes int drawableRes, @DrawableRes int checkedDrawableRes) { + mDefaultDrawable = drawableRes; + mCheckedDrawable = checkedDrawableRes; + } + + @Override + public void setChecked(boolean checked) { + mIcon.setImageResource(checked ? mCheckedDrawable : mDefaultDrawable); + } + + @Override + public void setMessageNumber(int number) { + //不需要就不用管 + } + + @Override + public void setHasMessage(boolean hasMessage) { + //不需要就不用管 + } + + @Override + public String getTitle() { + return "no title"; + } +} diff --git a/demo/src/main/java/com/simple/custom/OnlyTextTab.java b/demo/src/main/java/com/simple/custom/OnlyTextTab.java new file mode 100644 index 0000000..3d77a48 --- /dev/null +++ b/demo/src/main/java/com/simple/custom/OnlyTextTab.java @@ -0,0 +1,41 @@ +package com.simple.custom; + +import android.content.Context; +import android.view.LayoutInflater; +import android.widget.TextView; + +import com.bottom.item.BaseTabItem; +import com.simple.R; + +/** + * Created by mjj on 2017/9/26 + */ +public class OnlyTextTab extends BaseTabItem { + + private final TextView mTitle; + + public OnlyTextTab(Context context, String title) { + super(context); + LayoutInflater.from(context).inflate(R.layout.item_only_text, this, true); + mTitle = (TextView) findViewById(R.id.title); + mTitle.setText(title); + } + + @Override + public void setChecked(boolean checked) { + mTitle.setTextColor(checked ? 0xFFF4B400 : 0x56000000); + } + + @Override + public void setMessageNumber(int number) { + } + + @Override + public void setHasMessage(boolean hasMessage) { + } + + @Override + public String getTitle() { + return mTitle.getText().toString(); + } +} diff --git a/demo/src/main/java/com/simple/BottomItemTab.java b/demo/src/main/java/com/simple/custom/SpecialTab.java similarity index 62% rename from demo/src/main/java/com/simple/BottomItemTab.java rename to demo/src/main/java/com/simple/custom/SpecialTab.java index 36f2e9b..60b41f5 100644 --- a/demo/src/main/java/com/simple/BottomItemTab.java +++ b/demo/src/main/java/com/simple/custom/SpecialTab.java @@ -1,52 +1,58 @@ -package com.simple; +package com.simple.custom; import android.content.Context; import android.support.annotation.ColorInt; import android.support.annotation.DrawableRes; +import android.support.annotation.Nullable; import android.util.AttributeSet; import android.view.LayoutInflater; +import android.view.View; import android.widget.ImageView; import android.widget.TextView; +import com.bottom.internal.RoundMessageView; import com.bottom.item.BaseTabItem; +import com.simple.R; /** - * Created by songwenchao - * on 2017/12/29 0029. - *

- * 类名 - * 需要 -- - * 可以 -- + * Created by mjj on 2017/6/3 */ -public class BottomItemTab extends BaseTabItem { +public class SpecialTab extends BaseTabItem { private ImageView mIcon; private final TextView mTitle; - private final ImageView mMessages; + private final RoundMessageView mMessages; private int mDefaultDrawable; private int mCheckedDrawable; private int mDefaultTextColor = 0x56000000; private int mCheckedTextColor = 0x56000000; - private boolean isCheck = false; - public BottomItemTab(Context context) { + public SpecialTab(Context context) { this(context, null); } - public BottomItemTab(Context context, AttributeSet attrs) { + public SpecialTab(Context context, AttributeSet attrs) { this(context, attrs, 0); } - public BottomItemTab(Context context, AttributeSet attrs, int defStyleAttr) { + public SpecialTab(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - LayoutInflater.from(context).inflate(R.layout.view_bottom_tab, this, true); + LayoutInflater.from(context).inflate(R.layout.special_tab, this, true); - mIcon = (ImageView) findViewById(R.id.view_bottom_tab_image); - mTitle = (TextView) findViewById(R.id.view_bottom_tab_title); - mMessages = (ImageView) findViewById(R.id.view_bottom_tab_msg); + mIcon = (ImageView) findViewById(R.id.icon); + mTitle = (TextView) findViewById(R.id.title); + mMessages = (RoundMessageView) findViewById(R.id.messages); + } + + @Override + public void setOnClickListener(@Nullable OnClickListener l) { + View view = getChildAt(0); + if (view != null) { + view.setOnClickListener(l); + } } /** @@ -62,18 +68,8 @@ public void initialize(@DrawableRes int drawableRes, @DrawableRes int checkedDra mTitle.setText(title); } - public void setData(@DrawableRes int drawableRes, @DrawableRes int checkedDrawableRes, String title) { - if (isCheck) { - mIcon.setImageResource(checkedDrawableRes); - } else { - mIcon.setImageResource(drawableRes); - } - mTitle.setText(title); - } - @Override public void setChecked(boolean checked) { - isCheck = checked; if (checked) { mIcon.setImageResource(mCheckedDrawable); mTitle.setTextColor(mCheckedTextColor); @@ -85,15 +81,12 @@ public void setChecked(boolean checked) { @Override public void setMessageNumber(int number) { - + mMessages.setMessageNumber(number); } @Override public void setHasMessage(boolean hasMessage) { - if (hasMessage) - mMessages.setVisibility(VISIBLE); - else - mMessages.setVisibility(GONE); + mMessages.setHasMessage(hasMessage); } @Override diff --git a/demo/src/main/java/com/simple/custom/SpecialTabRound.java b/demo/src/main/java/com/simple/custom/SpecialTabRound.java new file mode 100644 index 0000000..72fef86 --- /dev/null +++ b/demo/src/main/java/com/simple/custom/SpecialTabRound.java @@ -0,0 +1,94 @@ +package com.simple.custom; + +import android.content.Context; +import android.support.annotation.ColorInt; +import android.support.annotation.DrawableRes; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.widget.ImageView; +import android.widget.TextView; + +import com.bottom.internal.RoundMessageView; +import com.bottom.item.BaseTabItem; +import com.simple.R; + +/** + * Created by mjj on 2017/6/3 + */ +public class SpecialTabRound extends BaseTabItem { + + private ImageView mIcon; + private final TextView mTitle; + private final RoundMessageView mMessages; + + private int mDefaultDrawable; + private int mCheckedDrawable; + + private int mDefaultTextColor = 0x56000000; + private int mCheckedTextColor = 0x56000000; + + public SpecialTabRound(Context context) { + this(context, null); + } + + public SpecialTabRound(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public SpecialTabRound(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + + LayoutInflater.from(context).inflate(R.layout.special_tab_round, this, true); + + mIcon = (ImageView) findViewById(R.id.icon); + mTitle = (TextView) findViewById(R.id.title); + mMessages = (RoundMessageView) findViewById(R.id.messages); + } + + /** + * 方便初始化的方法 + * + * @param drawableRes 默认状态的图标 + * @param checkedDrawableRes 选中状态的图标 + * @param title 标题 + */ + public void initialize(@DrawableRes int drawableRes, @DrawableRes int checkedDrawableRes, String title) { + mDefaultDrawable = drawableRes; + mCheckedDrawable = checkedDrawableRes; + mTitle.setText(title); + } + + @Override + public void setChecked(boolean checked) { + if (checked) { + mIcon.setImageResource(mCheckedDrawable); + mTitle.setTextColor(mCheckedTextColor); + } else { + mIcon.setImageResource(mDefaultDrawable); + mTitle.setTextColor(mDefaultTextColor); + } + } + + @Override + public void setMessageNumber(int number) { + mMessages.setMessageNumber(number); + } + + @Override + public void setHasMessage(boolean hasMessage) { + mMessages.setHasMessage(hasMessage); + } + + @Override + public String getTitle() { + return mTitle.getText().toString(); + } + + public void setTextDefaultColor(@ColorInt int color) { + mDefaultTextColor = color; + } + + public void setTextCheckedColor(@ColorInt int color) { + mCheckedTextColor = color; + } +} diff --git a/demo/src/main/java/com/simple/custom/TestRepeatTab.java b/demo/src/main/java/com/simple/custom/TestRepeatTab.java new file mode 100644 index 0000000..e2a1b83 --- /dev/null +++ b/demo/src/main/java/com/simple/custom/TestRepeatTab.java @@ -0,0 +1,46 @@ +package com.simple.custom; + +import android.animation.ObjectAnimator; +import android.content.Context; +import android.util.AttributeSet; + +import com.simple.R; + +/** + * Created by mjj on 2017/10/19 + *

+ * 测试重复点击的触发 + *

+ */ +public class TestRepeatTab extends OnlyIconItemView { + + public TestRepeatTab(Context context) { + super(context); + } + + public TestRepeatTab(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public TestRepeatTab(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + ObjectAnimator mAnimator; + + @Override + public void onRepeat() { + super.onRepeat(); + + if (mAnimator == null) { + ObjectAnimator animator = ObjectAnimator.ofFloat(findViewById(R.id.icon), "Rotation", 0f, -360f); + animator.setDuration(375); + mAnimator = animator; + } + + if (!mAnimator.isStarted()) { + mAnimator.start(); + } + + } +} diff --git a/demo/src/main/java/com/simple/other/AFragment.java b/demo/src/main/java/com/simple/other/AFragment.java new file mode 100644 index 0000000..edc0e4b --- /dev/null +++ b/demo/src/main/java/com/simple/other/AFragment.java @@ -0,0 +1,34 @@ +package com.simple.other; + +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +public class AFragment extends Fragment { + private static final String ARG_C = "content"; + + public static AFragment newInstance(String content) { + Bundle args = new Bundle(); + args.putString(ARG_C, content); + AFragment fragment = new AFragment(); + fragment.setArguments(args); + return fragment; + } + + @Nullable + @Override + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + String content = getArguments().getString(ARG_C); + TextView textView = new TextView(getContext()); + textView.setTextSize(30); + textView.setGravity(Gravity.CENTER); + textView.setText("Test\n\n" + content); + textView.setBackgroundColor(0xFFececec); + return textView; + } +} diff --git a/demo/src/main/java/com/simple/other/MyViewPagerAdapter.java b/demo/src/main/java/com/simple/other/MyViewPagerAdapter.java new file mode 100644 index 0000000..d1a3021 --- /dev/null +++ b/demo/src/main/java/com/simple/other/MyViewPagerAdapter.java @@ -0,0 +1,25 @@ +package com.simple.other; + +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentPagerAdapter; + +public class MyViewPagerAdapter extends FragmentPagerAdapter { + + private int size; + + public MyViewPagerAdapter(FragmentManager fm, int size) { + super(fm); + this.size = size; + } + + @Override + public Fragment getItem(int position) { + return AFragment.newInstance(position + ""); + } + + @Override + public int getCount() { + return size; + } +} diff --git a/demo/src/main/java/com/simple/other/NoTouchViewPager.java b/demo/src/main/java/com/simple/other/NoTouchViewPager.java new file mode 100644 index 0000000..7031a56 --- /dev/null +++ b/demo/src/main/java/com/simple/other/NoTouchViewPager.java @@ -0,0 +1,30 @@ +package com.simple.other; + +import android.content.Context; +import android.support.v4.view.ViewPager; +import android.util.AttributeSet; +import android.view.MotionEvent; + +/** + * 使ViewPager不能滑动 + */ +public class NoTouchViewPager extends ViewPager { + + public NoTouchViewPager(Context context) { + super(context); + } + + public NoTouchViewPager(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + public boolean onTouchEvent(MotionEvent event) { + return false; + } + + @Override + public boolean onInterceptTouchEvent(MotionEvent event) { + return false; + } +} diff --git a/demo/src/main/res/drawable/ic_audiotrack_black_24dp.xml b/demo/src/main/res/drawable/ic_audiotrack_black_24dp.xml new file mode 100644 index 0000000..2f5c8ed --- /dev/null +++ b/demo/src/main/res/drawable/ic_audiotrack_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/demo/src/main/res/drawable/ic_book_black_24dp.xml b/demo/src/main/res/drawable/ic_book_black_24dp.xml new file mode 100644 index 0000000..f60519e --- /dev/null +++ b/demo/src/main/res/drawable/ic_book_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/demo/src/main/res/drawable/ic_favorite_gray_24dp.xml b/demo/src/main/res/drawable/ic_favorite_gray_24dp.xml new file mode 100644 index 0000000..e8ed65d --- /dev/null +++ b/demo/src/main/res/drawable/ic_favorite_gray_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/demo/src/main/res/drawable/ic_favorite_teal_24dp.xml b/demo/src/main/res/drawable/ic_favorite_teal_24dp.xml new file mode 100644 index 0000000..1859e71 --- /dev/null +++ b/demo/src/main/res/drawable/ic_favorite_teal_24dp.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/demo/src/main/res/drawable/ic_nearby_gray_24dp.xml b/demo/src/main/res/drawable/ic_nearby_gray_24dp.xml new file mode 100644 index 0000000..5611edb --- /dev/null +++ b/demo/src/main/res/drawable/ic_nearby_gray_24dp.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/demo/src/main/res/drawable/ic_nearby_teal_24dp.xml b/demo/src/main/res/drawable/ic_nearby_teal_24dp.xml new file mode 100644 index 0000000..4ede4c2 --- /dev/null +++ b/demo/src/main/res/drawable/ic_nearby_teal_24dp.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/demo/src/main/res/drawable/ic_news_black_24dp.xml b/demo/src/main/res/drawable/ic_news_black_24dp.xml new file mode 100644 index 0000000..aa0cc15 --- /dev/null +++ b/demo/src/main/res/drawable/ic_news_black_24dp.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/demo/src/main/res/drawable/ic_ondemand_video_black_24dp.xml b/demo/src/main/res/drawable/ic_ondemand_video_black_24dp.xml new file mode 100644 index 0000000..097e25b --- /dev/null +++ b/demo/src/main/res/drawable/ic_ondemand_video_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/demo/src/main/res/drawable/ic_restore_gray_24dp.xml b/demo/src/main/res/drawable/ic_restore_gray_24dp.xml new file mode 100644 index 0000000..840e84b --- /dev/null +++ b/demo/src/main/res/drawable/ic_restore_gray_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/demo/src/main/res/drawable/ic_restore_teal_24dp.xml b/demo/src/main/res/drawable/ic_restore_teal_24dp.xml new file mode 100644 index 0000000..c91f481 --- /dev/null +++ b/demo/src/main/res/drawable/ic_restore_teal_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/demo/src/main/res/drawable/selector_bg.xml b/demo/src/main/res/drawable/selector_bg.xml deleted file mode 100644 index b8408d1..0000000 --- a/demo/src/main/res/drawable/selector_bg.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/demo/src/main/res/drawable/special_tab_bg.xml b/demo/src/main/res/drawable/special_tab_bg.xml new file mode 100644 index 0000000..2daf7a2 --- /dev/null +++ b/demo/src/main/res/drawable/special_tab_bg.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/demo/src/main/res/drawable/special_tab_round_bg.xml b/demo/src/main/res/drawable/special_tab_round_bg.xml new file mode 100644 index 0000000..aa5ab7c --- /dev/null +++ b/demo/src/main/res/drawable/special_tab_round_bg.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/demo/src/main/res/drawable/tab_background.xml b/demo/src/main/res/drawable/tab_background.xml new file mode 100644 index 0000000..d9e9ba2 --- /dev/null +++ b/demo/src/main/res/drawable/tab_background.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/demo/src/main/res/drawable/tab_vertical_background.xml b/demo/src/main/res/drawable/tab_vertical_background.xml new file mode 100644 index 0000000..35f6868 --- /dev/null +++ b/demo/src/main/res/drawable/tab_vertical_background.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/demo/src/main/res/layout/activity_behavior.xml b/demo/src/main/res/layout/activity_behavior.xml new file mode 100644 index 0000000..213005c --- /dev/null +++ b/demo/src/main/res/layout/activity_behavior.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + diff --git a/demo/src/main/res/layout/activity_hide.xml b/demo/src/main/res/layout/activity_hide.xml new file mode 100644 index 0000000..25d13f9 --- /dev/null +++ b/demo/src/main/res/layout/activity_hide.xml @@ -0,0 +1,27 @@ + + + + + + + + + + diff --git a/demo/src/main/res/layout/activity_main.xml b/demo/src/main/res/layout/activity_main.xml index b4d4aef..ad59e87 100644 --- a/demo/src/main/res/layout/activity_main.xml +++ b/demo/src/main/res/layout/activity_main.xml @@ -1,20 +1,62 @@ - + android:layout_height="match_parent"> - + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingTop="@dimen/activity_vertical_margin"> - +