├── .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 |
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 |
19 |
20 |
25 |
26 |
31 |
32 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_move.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
18 |
19 |
23 |
24 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_normal.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
18 |
19 |
23 |
24 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_qihoo.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
18 |
19 |
23 |
24 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_tab_fragent.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
18 |
19 |
23 |
24 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_tab.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/bottombar_appgroup_grey_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xhdpi/bottombar_appgroup_grey_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/bottombar_appgroup_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xhdpi/bottombar_appgroup_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/bottombar_appgroup_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xhdpi/bottombar_appgroup_pressed.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/bottombar_game_grey_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xhdpi/bottombar_game_grey_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/bottombar_game_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xhdpi/bottombar_game_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/bottombar_game_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xhdpi/bottombar_game_pressed.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/bottombar_home_grey_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xhdpi/bottombar_home_grey_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/bottombar_home_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xhdpi/bottombar_home_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/bottombar_home_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xhdpi/bottombar_home_pressed.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/bottombar_manager_grey_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xhdpi/bottombar_manager_grey_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/bottombar_manager_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xhdpi/bottombar_manager_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/bottombar_manager_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xhdpi/bottombar_manager_pressed.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/bottombar_software_grey_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xhdpi/bottombar_software_grey_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/bottombar_software_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xhdpi/bottombar_software_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/bottombar_software_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xhdpi/bottombar_software_pressed.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xxhdpi/ic_background.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_bg1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xxhdpi/ic_bg1.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_bg2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xxhdpi/ic_bg2.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_bg3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xxhdpi/ic_bg3.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_bg4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xxhdpi/ic_bg4.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_administration_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xxxhdpi/ic_administration_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_administration_preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xxxhdpi/ic_administration_preview.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_boutique_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xxxhdpi/ic_boutique_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_boutique_preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xxxhdpi/ic_boutique_preview.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_game_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xxxhdpi/ic_game_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_game_preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xxxhdpi/ic_game_preview.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_software_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xxxhdpi/ic_software_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_software_preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/app/src/main/res/mipmap-xxxhdpi/ic_software_preview.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 | #00BCD4
8 | #E91E63
9 | #FF5722
10 | #4CAF50
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | XFragmentTabHost
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/tabhost/demo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.tabhost.demo;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | mavenCentral()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:2.1.0'
10 | classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
11 |
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | jcenter()
20 | }
21 | }
22 |
23 | task clean(type: Delete) {
24 | delete rootProject.buildDir
25 | }
26 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rukey7/XFragmentTabHost/15bbc3176c862d6fa3602647a4bda350ede59932/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "24.0.0 rc2"
6 |
7 | defaultConfig {
8 | minSdkVersion 14
9 | targetSdkVersion 23
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile fileTree(dir: 'libs', include: ['*.jar'])
23 | testCompile 'junit:junit:4.12'
24 | compile 'com.android.support:appcompat-v7:23.2.1'
25 | }
26 |
--------------------------------------------------------------------------------
/library/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 |
--------------------------------------------------------------------------------
/library/src/androidTest/java/com/dl7/tabhost/library/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.dl7.tabhost.library;
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 | }
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/library/src/main/java/com/dl7/tabhost/library/RippleDrawable.java:
--------------------------------------------------------------------------------
1 | package com.dl7.tabhost.library;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.ColorFilter;
6 | import android.graphics.Paint;
7 | import android.graphics.PixelFormat;
8 | import android.graphics.Rect;
9 | import android.graphics.RectF;
10 | import android.graphics.drawable.Animatable;
11 | import android.graphics.drawable.Drawable;
12 |
13 | /**
14 | * Created by long on 2016/6/27.
15 | * 波纹Drawable
16 | */
17 | public class RippleDrawable extends Drawable implements Animatable {
18 |
19 | /**
20 | * 3种模式:左边、中间和右边波纹
21 | */
22 | public static final int MODE_LEFT = 1;
23 | public static final int MODE_MIDDLE = 2;
24 | public static final int MODE_RIGHT = 3;
25 |
26 | private int mMode = MODE_MIDDLE;
27 | // 前景色和后景色画笔
28 | private Paint mPaintFront;
29 | private Paint mPaintBehind;
30 | // 用来绘制扇形的矩形框
31 | private RectF mRect;
32 | // 目标View的宽高的一半
33 | private int mHalfWidth;
34 | private int mHalfHeight;
35 | // 扩散半径
36 | private int mRadius;
37 | // 前景色和背景色的分割距离
38 | private int mDivideSpace;
39 | // 扩散满视图需要的距离,中点到斜角的距离
40 | private int mFullSpace;
41 | // 动画控制
42 | private ValueAnimator mValueAnimator;
43 |
44 |
45 | public RippleDrawable(int frontColor, int behindColor, int mode) {
46 | mPaintFront = new Paint(Paint.ANTI_ALIAS_FLAG);
47 | mPaintFront.setColor(frontColor);
48 | mPaintBehind = new Paint(Paint.ANTI_ALIAS_FLAG);
49 | mPaintBehind.setColor(behindColor);
50 | mRect = new RectF();
51 | mMode = mode;
52 | }
53 |
54 | @Override
55 | public void draw(Canvas canvas) {
56 | if (mRadius > mHalfWidth) {
57 | int count = canvas.save();
58 | canvas.drawCircle(mHalfWidth, mHalfHeight, mHalfWidth, mPaintBehind);
59 | canvas.restoreToCount(count);
60 | count = canvas.save();
61 | canvas.drawCircle(mHalfWidth, mHalfHeight, mDivideSpace, mPaintFront);
62 | canvas.restoreToCount(count);
63 | } else if (mRadius > mDivideSpace) {
64 | int count = canvas.save();
65 | canvas.drawCircle(mHalfWidth, mHalfHeight, mRadius, mPaintBehind);
66 | canvas.restoreToCount(count);
67 | count = canvas.save();
68 | canvas.drawCircle(mHalfWidth, mHalfHeight, mDivideSpace, mPaintFront);
69 | canvas.restoreToCount(count);
70 | } else {
71 | canvas.drawCircle(mHalfWidth, mHalfHeight, mRadius, mPaintFront);
72 | }
73 |
74 | // 左右两边才进行扇形绘制
75 | if (mMode != MODE_MIDDLE) {
76 | mRect.left = mHalfWidth - mRadius;
77 | mRect.right = mHalfWidth + mRadius;
78 | mRect.top = mHalfHeight - mRadius;
79 | mRect.bottom = mHalfHeight + mRadius;
80 | }
81 | if (mMode == MODE_LEFT) {
82 | canvas.drawArc(mRect, 90, 180, true, mPaintFront);
83 | } else if (mMode == MODE_RIGHT) {
84 | canvas.drawArc(mRect, -90, 180, true, mPaintFront);
85 | }
86 | }
87 |
88 | @Override
89 | public void setAlpha(int alpha) {
90 | }
91 |
92 | @Override
93 | public void setColorFilter(ColorFilter colorFilter) {
94 | }
95 |
96 | @Override
97 | public int getOpacity() {
98 | return PixelFormat.RGBA_8888;
99 | }
100 |
101 | @Override
102 | protected void onBoundsChange(Rect bounds) {
103 | super.onBoundsChange(bounds);
104 | mHalfHeight = (bounds.bottom - bounds.top) / 2;
105 | mHalfWidth = (bounds.right - bounds.left) / 2;
106 | mDivideSpace = Math.max(mHalfHeight, mHalfWidth) * 3 / 4;
107 | mFullSpace = (int) Math.sqrt(mHalfWidth * mHalfWidth + mHalfHeight * mHalfHeight);
108 | // 属性动画
109 | mValueAnimator = ValueAnimator.ofInt(0, mFullSpace);
110 | mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
111 | @Override
112 | public void onAnimationUpdate(ValueAnimator animation) {
113 | mRadius = (int) animation.getAnimatedValue();
114 | invalidateSelf();
115 | }
116 | });
117 | mValueAnimator.setDuration(200);
118 | start();
119 | }
120 |
121 |
122 | @Override
123 | public void start() {
124 | mValueAnimator.start();
125 | }
126 |
127 | @Override
128 | public void stop() {
129 | mValueAnimator.end();
130 | }
131 |
132 | @Override
133 | public boolean isRunning() {
134 | return mValueAnimator != null && mValueAnimator.isRunning();
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/library/src/main/java/com/dl7/tabhost/library/TabAnimHelper.java:
--------------------------------------------------------------------------------
1 | package com.dl7.tabhost.library;
2 |
3 | import android.animation.AnimatorSet;
4 | import android.animation.ArgbEvaluator;
5 | import android.animation.ObjectAnimator;
6 | import android.animation.ValueAnimator;
7 | import android.graphics.drawable.ClipDrawable;
8 | import android.graphics.drawable.Drawable;
9 | import android.os.Build;
10 | import android.util.TypedValue;
11 | import android.view.Gravity;
12 | import android.view.View;
13 | import android.widget.ImageView;
14 | import android.widget.TextView;
15 |
16 | /**
17 | * Created by long on 2016/4/15.
18 | * Tab动画帮助类
19 | */
20 | public class TabAnimHelper {
21 |
22 | /**
23 | * 改变Tab的顶部偏移
24 | * @param view
25 | * @param fromPadding
26 | * @param toPadding
27 | */
28 | public static void changeTopPadding(final View view, int fromPadding, int toPadding) {
29 | ValueAnimator animator = ValueAnimator.ofFloat(fromPadding, toPadding);
30 | animator.setDuration(150);
31 | animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
32 | @Override
33 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
34 | float animatedValue = (float) valueAnimator.getAnimatedValue();
35 | view.setPadding(view.getPaddingLeft(),
36 | (int) animatedValue,
37 | view.getPaddingRight(),
38 | view.getPaddingBottom());
39 | }
40 | });
41 | animator.start();
42 | }
43 |
44 | /**
45 | * 改变字体大小
46 | * @param textView
47 | * @param from
48 | * @param to
49 | */
50 | public static void changeTextSize(final TextView textView, float from, float to) {
51 | ValueAnimator textSizeChangeAnimator = ValueAnimator.ofFloat(from, to);
52 | textSizeChangeAnimator.setDuration(150);
53 | textSizeChangeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
54 | @Override
55 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
56 | textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) valueAnimator.getAnimatedValue());
57 | }
58 | });
59 | textSizeChangeAnimator.start();
60 | }
61 |
62 | /**
63 | * 改变字体颜色
64 | * @param textView
65 | * @param fromColor
66 | * @param toColor
67 | */
68 | public static void changeTextColor(final TextView textView, int fromColor, int toColor) {
69 | ValueAnimator changeTextColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), fromColor, toColor);
70 | changeTextColorAnimation.setDuration(150);
71 | changeTextColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
72 | @Override
73 | public void onAnimationUpdate(ValueAnimator animator) {
74 | textView.setTextColor((Integer) animator.getAnimatedValue());
75 | }
76 | });
77 | changeTextColorAnimation.start();
78 | }
79 |
80 | /**
81 | * 改变视图大小
82 | * @param image
83 | * @param fromScale
84 | * @param toScale
85 | */
86 | public static void changeImageSize(ImageView image, float fromScale, float toScale) {
87 | ObjectAnimator scaleX;
88 | ObjectAnimator scaleY;
89 | scaleX = ObjectAnimator.ofFloat(image, "scaleX", fromScale, toScale);
90 | scaleY = ObjectAnimator.ofFloat(image, "scaleY", fromScale, toScale);
91 | AnimatorSet set = new AnimatorSet();
92 | set.setDuration(150);
93 | set.playTogether(scaleX, scaleY);
94 | set.start();
95 | }
96 |
97 | /**
98 | * 从中心展开Drawable
99 | * @param image
100 | * @param drawable
101 | * @param isActivated
102 | */
103 | @SuppressWarnings("deprecation")
104 | public static void clipDrawable(final View image, Drawable drawable, boolean isActivated) {
105 | if (drawable == null) {
106 | return;
107 | }
108 | if (isActivated) {
109 | final ClipDrawable scaleDrawable = new ClipDrawable(drawable, Gravity.CENTER,
110 | ClipDrawable.HORIZONTAL | ClipDrawable.VERTICAL);
111 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
112 | image.setBackground(scaleDrawable);
113 | } else {
114 | image.setBackgroundDrawable(scaleDrawable);
115 | }
116 | image.setBackgroundDrawable(scaleDrawable);
117 | ValueAnimator animator = ValueAnimator.ofInt(0, 10000);
118 | animator.setDuration(200);
119 | animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
120 | @Override
121 | public void onAnimationUpdate(ValueAnimator animation) {
122 | scaleDrawable.setLevel((Integer) animation.getAnimatedValue());
123 | }
124 | });
125 | animator.start();
126 | } else {
127 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
128 | image.setBackground(null);
129 | } else {
130 | image.setBackgroundDrawable(null);
131 | }
132 | }
133 | }
134 |
135 | /**
136 | * 波纹动画
137 | * @param view
138 | * @param frontColor
139 | * @param behindColor
140 | * @param mode
141 | * @param isActivated
142 | */
143 | @SuppressWarnings("deprecation")
144 | public static void rippleDrawable(final View view, int frontColor, int behindColor, int mode, boolean isActivated) {
145 | if (isActivated) {
146 | RippleDrawable rippleDrawable = new RippleDrawable(frontColor, behindColor, mode);
147 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
148 | view.setBackground(rippleDrawable);
149 | } else {
150 | view.setBackgroundDrawable(rippleDrawable);
151 | }
152 | } else {
153 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
154 | view.setBackground(null);
155 | } else {
156 | view.setBackgroundDrawable(null);
157 | }
158 | }
159 | }
160 | }
161 |
--------------------------------------------------------------------------------
/library/src/main/java/com/dl7/tabhost/library/TabItem.java:
--------------------------------------------------------------------------------
1 | package com.dl7.tabhost.library;
2 |
3 | import android.graphics.drawable.Drawable;
4 |
5 | /**
6 | * Created by long on 2016/4/15.
7 | * Tab项
8 | */
9 | public class TabItem {
10 |
11 | private String title;
12 | private Drawable drawable;
13 | private int imageRes;
14 |
15 | public TabItem(String title, Drawable drawable, int imageRes) {
16 | this.title = title;
17 | this.drawable = drawable;
18 | this.imageRes = imageRes;
19 | }
20 |
21 | public TabItem(String title, int imageRes) {
22 | this.title = title;
23 | this.drawable = null;
24 | this.imageRes = imageRes;
25 | }
26 |
27 | public String getTitle() {
28 | return title;
29 | }
30 |
31 | public void setTitle(String title) {
32 | this.title = title;
33 | }
34 |
35 | public Drawable getDrawable() {
36 | return drawable;
37 | }
38 |
39 | public void setDrawable(Drawable drawable) {
40 | this.drawable = drawable;
41 | }
42 |
43 | public int getImageRes() {
44 | return imageRes;
45 | }
46 |
47 | public void setImageRes(int imageRes) {
48 | this.imageRes = imageRes;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/library/src/main/java/com/dl7/tabhost/library/XFragmentTabHost.java:
--------------------------------------------------------------------------------
1 | package com.dl7.tabhost.library;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 | import android.support.v4.app.FragmentTabHost;
6 | import android.support.v4.content.ContextCompat;
7 | import android.util.AttributeSet;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.widget.ImageView;
11 | import android.widget.TextView;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | /**
17 | * Created by long on 2016/4/15.
18 | * 扩展TabHost
19 | */
20 | public class XFragmentTabHost extends FragmentTabHost {
21 |
22 | private Context mContext;
23 | private List mTabViews;
24 | private List mTabItems;
25 | // 字体激活颜色
26 | private int mTextActiveColor;
27 | private int mTextInactiveColor;
28 | // 字体激活大小
29 | private float mTextActiveSize;
30 | private float mTextInactiveSize;
31 | // 视图激活对顶部的偏移
32 | private int mViewActivePaddingTop;
33 | private int mViewInactivePaddingTop;
34 | // 波纹模式的前景颜色和后景颜色
35 | private int mFrontColor;
36 | private int mBehindColor;
37 | // TabHost模式
38 | private TabMode mTabMode;
39 |
40 |
41 | public XFragmentTabHost(Context context) {
42 | super(context);
43 | _init(context);
44 | }
45 |
46 | public XFragmentTabHost(Context context, AttributeSet attrs) {
47 | super(context, attrs);
48 | _init(context);
49 | }
50 |
51 | private void _init(Context context) {
52 | mTabViews = new ArrayList<>();
53 | mTabItems = new ArrayList<>();
54 | mContext = context;
55 | mTextActiveColor = ContextCompat.getColor(mContext, R.color.colorActive);
56 | mTextInactiveColor = ContextCompat.getColor(mContext, R.color.colorInactive);
57 | mFrontColor = ContextCompat.getColor(mContext, R.color.colorFront);
58 | mBehindColor = ContextCompat.getColor(mContext, R.color.colorBehind);
59 | mTextActiveSize = getResources().getDimension(R.dimen.tab_text_size_active);
60 | mTextInactiveSize = getResources().getDimension(R.dimen.tab_text_size_inactive);
61 | mViewActivePaddingTop = (int) getResources().getDimension(R.dimen.tab_padding_top_active);
62 | mViewInactivePaddingTop = (int) getResources().getDimension(R.dimen.tab_padding_top_inactive);
63 | mTabMode = TabMode.MoveToTop;
64 | }
65 |
66 | /**
67 | * 覆写父类接口,并在这里做些动画特效
68 | * @param index 当前选中的Tab项
69 | */
70 | @Override
71 | public void setCurrentTab(int index) {
72 | // 获取之前选中的index
73 | int lastIndex = getCurrentTab();
74 | super.setCurrentTab(index);
75 | // 选中不同的Tab项才做切换处理
76 | if (lastIndex != index) {
77 | _switchTab(lastIndex, index);
78 | }
79 | }
80 |
81 | @Override
82 | protected void onAttachedToWindow() {
83 | super.onAttachedToWindow();
84 | // 部分机型TabHost带有分割线,同一将分割线设为透明
85 | getTabWidget().setDividerDrawable(android.R.color.transparent);
86 | }
87 |
88 | /**
89 | * 添加TabItem
90 | * @param item TabItem
91 | * @param fragClass fragment类名
92 | * @param bundle 传给fragment的参数
93 | */
94 | public void addTabItem(TabItem item, Class> fragClass, Bundle bundle) {
95 | mTabItems.add(item);
96 | View view = _getIndicator(item);
97 | mTabViews.add(view);
98 | this.addTab(newTabSpec(item.getTitle()).setIndicator(view), fragClass, bundle);
99 | }
100 |
101 | /**
102 | * 获取TabItem视图
103 | * @param item TabItem
104 | * @return
105 | */
106 | private View _getIndicator(TabItem item) {
107 | View view = LayoutInflater.from(mContext).inflate(R.layout.tab_indicator, null);
108 | ImageView imageView = (ImageView) view.findViewById(R.id.tab_icon);
109 | TextView title = (TextView) view.findViewById(R.id.tab_title);
110 | imageView.setImageResource(item.getImageRes());
111 | title.setText(item.getTitle());
112 | title.setTextColor(mTextInactiveColor);
113 | return view;
114 | }
115 |
116 | /**
117 | * 切换Tab
118 | * @param lastIndex 上一个选中索引
119 | * @param nextIndex 下一个选中索引
120 | */
121 | private void _switchTab(int lastIndex, int nextIndex) {
122 | for (int i = 0; i < mTabViews.size(); i++) {
123 | if (i == lastIndex) {
124 | _switchView(i, false);
125 | } else if (i == nextIndex) {
126 | _switchView(i, true);
127 | }
128 | }
129 | }
130 |
131 | /**
132 | * 切换视图
133 | * @param index 索引
134 | * @param isActivated 是否激活
135 | */
136 | private void _switchView(int index, boolean isActivated) {
137 | switch (mTabMode) {
138 | case MoveToTop:
139 | _doMoveToTop(index, isActivated);
140 | break;
141 | case ClipDrawable:
142 | _doClipDrawable(index, isActivated);
143 | break;
144 | case Ripple:
145 | _doRipple(index, isActivated);
146 | break;
147 | }
148 | }
149 |
150 | /**
151 | * 背景展开处理
152 | * @param index 索引
153 | * @param isActivated 是否激活
154 | */
155 | private void _doClipDrawable(int index, boolean isActivated) {
156 | View view = mTabViews.get(index);
157 | View tabView = view.findViewById(R.id.tab_layout);
158 | if (isActivated) {
159 | TabAnimHelper.clipDrawable(tabView, mTabItems.get(index).getDrawable(), true);
160 | } else {
161 | TabAnimHelper.clipDrawable(tabView, mTabItems.get(index).getDrawable(), false);
162 | }
163 | }
164 |
165 | /**
166 | * 波纹处理
167 | * @param index 索引
168 | * @param isActivated 是否激活
169 | */
170 | private void _doRipple(int index, boolean isActivated) {
171 | View view = mTabViews.get(index);
172 | View tabView = view.findViewById(R.id.tab_layout);
173 | TextView title = (TextView) view.findViewById(R.id.tab_title);
174 | if (index == 0) {
175 | TabAnimHelper.rippleDrawable(tabView, mFrontColor, mBehindColor, RippleDrawable.MODE_LEFT, isActivated);
176 | } else if (index == (mTabViews.size() - 1)){
177 | TabAnimHelper.rippleDrawable(tabView, mFrontColor, mBehindColor, RippleDrawable.MODE_RIGHT, isActivated);
178 | } else {
179 | TabAnimHelper.rippleDrawable(tabView, mFrontColor, mBehindColor, RippleDrawable.MODE_MIDDLE, isActivated);
180 | }
181 | if (isActivated) {
182 | title.setTextColor(mTextActiveColor);
183 | } else {
184 | title.setTextColor(mTextInactiveColor);
185 | }
186 | }
187 |
188 | /**
189 | * 上移动画处理
190 | * @param index 索引
191 | * @param isActivated 是否激活
192 | */
193 | private void _doMoveToTop(int index, boolean isActivated) {
194 | View view = mTabViews.get(index);
195 | TextView title = (TextView) view.findViewById(R.id.tab_title);
196 | ImageView icon = (ImageView) view.findViewById(R.id.tab_icon);
197 | if (isActivated) {
198 | TabAnimHelper.changeTextColor(title, mTextInactiveColor, mTextActiveColor);
199 | TabAnimHelper.changeTextSize(title, mTextInactiveSize, mTextActiveSize);
200 | TabAnimHelper.changeTopPadding(view, mViewInactivePaddingTop, mViewActivePaddingTop);
201 | TabAnimHelper.changeImageSize(icon, 1.0f, 1.1f);
202 | } else {
203 | TabAnimHelper.changeTextColor(title, mTextActiveColor, mTextInactiveColor);
204 | TabAnimHelper.changeTextSize(title, mTextActiveSize, mTextInactiveSize);
205 | TabAnimHelper.changeTopPadding(view, mViewActivePaddingTop, mViewInactivePaddingTop);
206 | TabAnimHelper.changeImageSize(icon, 1.1f, 1.0f);
207 | }
208 | }
209 |
210 |
211 | /**
212 | * 属性设置
213 | * @return
214 | */
215 | public int getTextActiveColor() {
216 | return mTextActiveColor;
217 | }
218 |
219 | public void setTextActiveColor(int textActiveColor) {
220 | mTextActiveColor = textActiveColor;
221 | }
222 |
223 | public int getTextInactiveColor() {
224 | return mTextInactiveColor;
225 | }
226 |
227 | public void setTextInactiveColor(int textInactiveColor) {
228 | mTextInactiveColor = textInactiveColor;
229 | }
230 |
231 | public int getFrontColor() {
232 | return mFrontColor;
233 | }
234 |
235 | public void setFrontColor(int frontColor) {
236 | mFrontColor = frontColor;
237 | }
238 |
239 | public int getBehindColor() {
240 | return mBehindColor;
241 | }
242 |
243 | public void setBehindColor(int behindColor) {
244 | mBehindColor = behindColor;
245 | }
246 |
247 | public TabMode getTabMode() {
248 | return mTabMode;
249 | }
250 |
251 | public void setTabMode(TabMode tabMode) {
252 | mTabMode = tabMode;
253 | }
254 |
255 | /**
256 | * Tab的模式
257 | * MoveToTop:向上偏移
258 | * Ripple:波纹
259 | * ClipDrawable:逐步展示背景
260 | */
261 | public enum TabMode {
262 |
263 | MoveToTop(1),
264 | Ripple(2),
265 | ClipDrawable(3);
266 |
267 | private int tabMode;
268 |
269 | TabMode(int tabMode) {
270 | this.tabMode = tabMode;
271 | }
272 |
273 | public int getTabMode() {
274 | return tabMode;
275 | }
276 | }
277 | }
278 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/tab_indicator.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
17 |
18 |
27 |
28 |
--------------------------------------------------------------------------------
/library/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #00BCD4
5 | #d2d0d1
6 | #4db6ac
7 | #84ffff
8 |
--------------------------------------------------------------------------------
/library/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 8dp
5 | 3dp
6 | 4dp
7 | 104dp
8 | 168dp
9 | 56dp
10 | 1dp
11 | 24dp
12 |
13 | 3dp
14 | 6dp
15 | 16dp
16 | 3dp
17 | 12dp
18 | 12dp
19 | 14sp
20 | 12sp
21 |
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Library
3 |
4 |
--------------------------------------------------------------------------------
/library/src/test/java/com/dl7/tabhost/library/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.dl7.tabhost.library;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':library'
2 |
--------------------------------------------------------------------------------