├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── tabhost │ │ └── demo │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── tabhost │ │ │ └── demo │ │ │ ├── TabFragment.java │ │ │ └── activity │ │ │ ├── ClipActivity.java │ │ │ ├── MainActivity.java │ │ │ ├── MoveActivity.java │ │ │ ├── NormalActivity.java │ │ │ └── QihooActivity.java │ └── res │ │ ├── drawable │ │ ├── layer_bg.xml │ │ ├── loading_inner_bg.xml │ │ ├── loading_outer_bg.xml │ │ ├── sel_360_app.xml │ │ ├── sel_360_game.xml │ │ ├── sel_360_home.xml │ │ ├── sel_360_mag.xml │ │ ├── sel_360_software.xml │ │ ├── sel_tab_app.xml │ │ ├── sel_tab_game.xml │ │ ├── sel_tab_home.xml │ │ ├── sel_tab_mag.xml │ │ └── shadow.xml │ │ ├── layout │ │ ├── activity_clip.xml │ │ ├── activity_main.xml │ │ ├── activity_move.xml │ │ ├── activity_normal.xml │ │ ├── activity_qihoo.xml │ │ ├── activity_tab_fragent.xml │ │ └── fragment_tab.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ ├── bottombar_appgroup_grey_normal.png │ │ ├── bottombar_appgroup_normal.png │ │ ├── bottombar_appgroup_pressed.png │ │ ├── bottombar_game_grey_normal.png │ │ ├── bottombar_game_normal.png │ │ ├── bottombar_game_pressed.png │ │ ├── bottombar_home_grey_normal.png │ │ ├── bottombar_home_normal.png │ │ ├── bottombar_home_pressed.png │ │ ├── bottombar_manager_grey_normal.png │ │ ├── bottombar_manager_normal.png │ │ ├── bottombar_manager_pressed.png │ │ ├── bottombar_software_grey_normal.png │ │ ├── bottombar_software_normal.png │ │ ├── bottombar_software_pressed.png │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_background.png │ │ ├── ic_bg1.png │ │ ├── ic_bg2.png │ │ ├── ic_bg3.png │ │ ├── ic_bg4.png │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_administration_normal.png │ │ ├── ic_administration_preview.png │ │ ├── ic_boutique_normal.png │ │ ├── ic_boutique_preview.png │ │ ├── ic_game_normal.png │ │ ├── ic_game_preview.png │ │ ├── ic_launcher.png │ │ ├── ic_software_normal.png │ │ └── ic_software_preview.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── tabhost │ └── demo │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── dl7 │ │ └── tabhost │ │ └── library │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── dl7 │ │ │ └── tabhost │ │ │ └── library │ │ │ ├── RippleDrawable.java │ │ │ ├── TabAnimHelper.java │ │ │ ├── TabItem.java │ │ │ └── XFragmentTabHost.java │ └── res │ │ ├── layout │ │ └── tab_indicator.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── dl7 │ └── tabhost │ └── library │ └── ExampleUnitTest.java └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # XFragmentTabHost 2 | 对FragmentTabHost的扩展,增加动画效果 3 | 4 | Demo 5 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "24.0.0 rc2" 6 | 7 | defaultConfig { 8 | applicationId "com.tabhost.demo" 9 | minSdkVersion 14 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(include: ['*.jar'], dir: 'libs') 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.2.1' 26 | compile project(':library') 27 | } 28 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in F:\WorkTools\Android\SDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/tabhost/demo/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.tabhost.demo; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/tabhost/demo/TabFragment.java: -------------------------------------------------------------------------------- 1 | package com.tabhost.demo; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.TextView; 10 | 11 | /** 12 | * Created by long on 2016/4/15. 13 | */ 14 | public class TabFragment extends Fragment { 15 | 16 | public static final String FRAG_KEY = "FragKey"; 17 | private TextView mFragTabText; 18 | 19 | private void assignViews(View view) { 20 | mFragTabText = (TextView) view.findViewById(R.id.frag_tab_text); 21 | } 22 | 23 | 24 | @Nullable 25 | @Override 26 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 27 | View view = inflater.inflate(R.layout.fragment_tab, null); 28 | assignViews(view); 29 | return view; 30 | } 31 | 32 | @Override 33 | public void onActivityCreated(@Nullable Bundle savedInstanceState) { 34 | super.onActivityCreated(savedInstanceState); 35 | if (getArguments() != null) { 36 | String title = getArguments().getString(FRAG_KEY); 37 | mFragTabText.setText(title); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/tabhost/demo/activity/ClipActivity.java: -------------------------------------------------------------------------------- 1 | package com.tabhost.demo.activity; 2 | 3 | import android.graphics.drawable.Drawable; 4 | import android.os.Bundle; 5 | import android.support.v4.content.ContextCompat; 6 | import android.support.v7.app.AppCompatActivity; 7 | 8 | import com.dl7.tabhost.library.TabItem; 9 | import com.dl7.tabhost.library.XFragmentTabHost; 10 | import com.tabhost.demo.R; 11 | import com.tabhost.demo.TabFragment; 12 | 13 | public class ClipActivity extends AppCompatActivity { 14 | 15 | private XFragmentTabHost mTabHost; 16 | String[] mTabTitle = new String[] {"首页", "软件", "游戏", "管理"}; 17 | int[] mImageResId = new int[] {R.drawable.sel_tab_home, R.drawable.sel_tab_app, 18 | R.drawable.sel_tab_game, R.drawable.sel_tab_mag}; 19 | Class[] mFragClass = new Class[] {TabFragment.class, TabFragment.class, 20 | TabFragment.class, TabFragment.class}; 21 | 22 | @Override 23 | protected void onCreate(Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | setContentView(R.layout.activity_clip); 26 | _initTabHost(); 27 | } 28 | 29 | private void _initTabHost() { 30 | Drawable[] drawables = new Drawable[] { ContextCompat.getDrawable(this, R.mipmap.ic_bg1), 31 | ContextCompat.getDrawable(this, R.mipmap.ic_bg2), 32 | ContextCompat.getDrawable(this, R.mipmap.ic_bg3), 33 | ContextCompat.getDrawable(this, R.mipmap.ic_bg4)}; 34 | 35 | mTabHost = (XFragmentTabHost) findViewById(android.R.id.tabhost); 36 | mTabHost.setup(this, getSupportFragmentManager(), R.id.relate_tab_content); 37 | mTabHost.setTabMode(XFragmentTabHost.TabMode.ClipDrawable); 38 | 39 | for (int i = 0; i < mFragClass.length; i++) { 40 | Bundle bundle = new Bundle(); 41 | bundle.putString(TabFragment.FRAG_KEY, mTabTitle[i]); 42 | mTabHost.addTabItem(new TabItem(mTabTitle[i], drawables[i], mImageResId[i]), 43 | mFragClass[i], bundle); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/tabhost/demo/activity/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.tabhost.demo.activity; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.view.View; 7 | import android.widget.Button; 8 | 9 | import com.tabhost.demo.R; 10 | 11 | public class MainActivity extends AppCompatActivity implements View.OnClickListener { 12 | 13 | private Button mBtnNormal; 14 | private Button mBtnMove; 15 | private Button mBtnRipple; 16 | private Button mBtnClip; 17 | 18 | private void assignViews() { 19 | mBtnNormal = (Button) findViewById(R.id.btn_normal); 20 | mBtnMove = (Button) findViewById(R.id.btn_move); 21 | mBtnRipple = (Button) findViewById(R.id.btn_ripple); 22 | mBtnClip = (Button) findViewById(R.id.btn_clip); 23 | mBtnNormal.setOnClickListener(this); 24 | mBtnMove.setOnClickListener(this); 25 | mBtnRipple.setOnClickListener(this); 26 | mBtnClip.setOnClickListener(this); 27 | } 28 | 29 | @Override 30 | protected void onCreate(Bundle savedInstanceState) { 31 | super.onCreate(savedInstanceState); 32 | setContentView(R.layout.activity_main); 33 | assignViews(); 34 | } 35 | 36 | @Override 37 | public void onClick(View v) { 38 | switch (v.getId()) { 39 | case R.id.btn_normal: 40 | startActivity(new Intent(MainActivity.this, NormalActivity.class)); 41 | break; 42 | case R.id.btn_clip: 43 | startActivity(new Intent(MainActivity.this, ClipActivity.class)); 44 | break; 45 | case R.id.btn_ripple: 46 | startActivity(new Intent(MainActivity.this, QihooActivity.class)); 47 | break; 48 | case R.id.btn_move: 49 | startActivity(new Intent(MainActivity.this, MoveActivity.class)); 50 | break; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /app/src/main/java/com/tabhost/demo/activity/MoveActivity.java: -------------------------------------------------------------------------------- 1 | package com.tabhost.demo.activity; 2 | 3 | import android.graphics.Color; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | 7 | import com.dl7.tabhost.library.TabItem; 8 | import com.dl7.tabhost.library.XFragmentTabHost; 9 | import com.tabhost.demo.R; 10 | import com.tabhost.demo.TabFragment; 11 | 12 | public class MoveActivity extends AppCompatActivity { 13 | 14 | private XFragmentTabHost mTabHost; 15 | String[] mTabTitle = new String[] {"首页", "软件", "游戏", "管理"}; 16 | int[] mImageResId = new int[] {R.drawable.sel_tab_home, R.drawable.sel_tab_app, 17 | R.drawable.sel_tab_game, R.drawable.sel_tab_mag}; 18 | Class[] mFragClass = new Class[] {TabFragment.class, TabFragment.class, 19 | TabFragment.class, TabFragment.class}; 20 | 21 | @Override 22 | protected void onCreate(Bundle savedInstanceState) { 23 | super.onCreate(savedInstanceState); 24 | setContentView(R.layout.activity_move); 25 | _initTabHost(); 26 | } 27 | 28 | private void _initTabHost() { 29 | mTabHost = (XFragmentTabHost) findViewById(android.R.id.tabhost); 30 | mTabHost.setup(this, getSupportFragmentManager(), R.id.relate_tab_content); 31 | mTabHost.setTabMode(XFragmentTabHost.TabMode.MoveToTop); 32 | mTabHost.setTextActiveColor(Color.BLUE); 33 | 34 | for (int i = 0; i < mFragClass.length; i++) { 35 | Bundle bundle = new Bundle(); 36 | bundle.putString(TabFragment.FRAG_KEY, mTabTitle[i]); 37 | mTabHost.addTabItem(new TabItem(mTabTitle[i], mImageResId[i]), mFragClass[i], bundle); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/tabhost/demo/activity/NormalActivity.java: -------------------------------------------------------------------------------- 1 | package com.tabhost.demo.activity; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.FragmentTabHost; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.widget.ImageView; 9 | import android.widget.TextView; 10 | 11 | import com.tabhost.demo.R; 12 | import com.tabhost.demo.TabFragment; 13 | 14 | public class NormalActivity extends AppCompatActivity { 15 | 16 | private FragmentTabHost mTabHost; 17 | private String[] mTabTitle = new String[] {"首页", "软件", "游戏", "管理"}; 18 | private int[] mImageResId = new int[] {R.drawable.sel_tab_home, R.drawable.sel_tab_app, 19 | R.drawable.sel_tab_game, R.drawable.sel_tab_mag}; 20 | private Class[] mFragClass = new Class[] {TabFragment.class, TabFragment.class, 21 | TabFragment.class, TabFragment.class}; 22 | 23 | @Override 24 | protected void onCreate(Bundle savedInstanceState) { 25 | super.onCreate(savedInstanceState); 26 | setContentView(R.layout.activity_normal); 27 | _initTabHost(); 28 | } 29 | 30 | private void _initTabHost() { 31 | mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); 32 | mTabHost.setup(this, getSupportFragmentManager(), R.id.relate_tab_content); 33 | 34 | for (int i = 0; i < mFragClass.length; i++) { 35 | Bundle bundle = new Bundle(); 36 | bundle.putString(TabFragment.FRAG_KEY, mTabTitle[i]); 37 | mTabHost.addTab(mTabHost.newTabSpec(mTabTitle[i]).setIndicator(_getIndicator(i)), mFragClass[i], bundle); 38 | } 39 | } 40 | 41 | private View _getIndicator(int index) { 42 | View view = LayoutInflater.from(this).inflate(R.layout.tab_indicator, null); 43 | ImageView imageView = (ImageView) view.findViewById(R.id.tab_icon); 44 | TextView title = (TextView) view.findViewById(R.id.tab_title); 45 | imageView.setImageResource(mImageResId[index]); 46 | title.setText(mTabTitle[index]); 47 | return view; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/tabhost/demo/activity/QihooActivity.java: -------------------------------------------------------------------------------- 1 | package com.tabhost.demo.activity; 2 | 3 | import android.graphics.Color; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | 7 | import com.dl7.tabhost.library.TabItem; 8 | import com.dl7.tabhost.library.XFragmentTabHost; 9 | import com.tabhost.demo.R; 10 | import com.tabhost.demo.TabFragment; 11 | 12 | public class QihooActivity extends AppCompatActivity { 13 | 14 | private XFragmentTabHost mTabHost; 15 | String[] mTabTitle = new String[] {"首页", "游戏", "软件", "应用圈", "管理"}; 16 | int[] mImageResId = new int[] {R.drawable.sel_360_home, R.drawable.sel_360_game, R.drawable.sel_360_software, 17 | R.drawable.sel_360_app, R.drawable.sel_360_mag}; 18 | Class[] mFragClass = new Class[] {TabFragment.class, TabFragment.class, 19 | TabFragment.class, TabFragment.class, TabFragment.class}; 20 | 21 | private void initTabHost() { 22 | 23 | mTabHost = (XFragmentTabHost) findViewById(android.R.id.tabhost); 24 | mTabHost.setup(this, getSupportFragmentManager(), R.id.relate_tab_content); 25 | mTabHost.setTabMode(XFragmentTabHost.TabMode.Ripple); 26 | mTabHost.setTextActiveColor(Color.WHITE); 27 | mTabHost.setTextInactiveColor(Color.GRAY); 28 | // mTabHost.setFrontColor(Color.RED); 29 | // mTabHost.setBehindColor(Color.GREEN); 30 | 31 | for (int i = 0; i < mFragClass.length; i++) { 32 | Bundle bundle = new Bundle(); 33 | bundle.putString(TabFragment.FRAG_KEY, mTabTitle[i]); 34 | mTabHost.addTabItem(new TabItem(mTabTitle[i], mImageResId[i]), 35 | mFragClass[i], bundle); 36 | } 37 | } 38 | 39 | @Override 40 | protected void onCreate(Bundle savedInstanceState) { 41 | super.onCreate(savedInstanceState); 42 | setContentView(R.layout.activity_qihoo); 43 | initTabHost(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/layer_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/loading_inner_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/loading_outer_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/sel_360_app.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/sel_360_game.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/sel_360_home.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/sel_360_mag.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/sel_360_software.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/sel_tab_app.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/sel_tab_game.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/sel_tab_home.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/sel_tab_mag.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shadow.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_clip.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 18 | 19 | 23 | 24 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 |