-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b2b9ca
commit 16792f4
Showing
85 changed files
with
1,514 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,42 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.simple"> | ||
package="com.simple"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
|
||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER"/> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
<activity android:name=".MaterialDesignActivity" /> | ||
|
||
<activity android:name=".CustomActivity" /> | ||
|
||
<activity android:name=".Custom2Activity" /> | ||
|
||
<activity | ||
android:name=".BehaviorActivity" | ||
android:theme="@style/AppTheme.NoActionBar" /> | ||
|
||
<activity | ||
android:name=".HideActivity" | ||
android:theme="@style/AppTheme.NoActionBar" /> | ||
|
||
<activity android:name=".SpecialActivity" /> | ||
|
||
<activity android:name=".VerticalActivity" /> | ||
|
||
<activity android:name=".VerticalCustomActivity" /> | ||
|
||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package com.simple; | ||
|
||
import android.os.Bundle; | ||
import android.support.annotation.Nullable; | ||
import android.support.v4.app.Fragment; | ||
import android.support.v4.app.FragmentManager; | ||
import android.support.v4.app.FragmentPagerAdapter; | ||
import android.support.v4.view.ViewPager; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.DividerItemDecoration; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.support.v7.widget.Toolbar; | ||
import android.util.TypedValue; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.TextView; | ||
|
||
import com.bottom.NavigationController; | ||
import com.bottom.PageNavigationView; | ||
|
||
public class BehaviorActivity extends AppCompatActivity { | ||
|
||
NavigationController mNavigationController; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_behavior); | ||
|
||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | ||
setSupportActionBar(toolbar); | ||
|
||
PageNavigationView pageBottomTabLayout = (PageNavigationView) findViewById(R.id.tab); | ||
|
||
mNavigationController = pageBottomTabLayout.material() | ||
.addItem(R.drawable.ic_restore_teal_24dp, "Recents") | ||
.addItem(R.drawable.ic_favorite_teal_24dp, "Favorites") | ||
.addItem(R.drawable.ic_nearby_teal_24dp, "Nearby") | ||
.build(); | ||
|
||
ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager); | ||
viewPager.setAdapter(new TestViewPagerAdapter(getSupportFragmentManager())); | ||
|
||
mNavigationController.setupWithViewPager(viewPager); | ||
} | ||
|
||
//下面几个类都是为了测试写的 | ||
private class TestViewPagerAdapter extends FragmentPagerAdapter { | ||
|
||
public TestViewPagerAdapter(FragmentManager fm) { | ||
super(fm); | ||
} | ||
|
||
@Override | ||
public Fragment getItem(int position) { | ||
return new TestFragment(); | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
return mNavigationController.getItemCount(); | ||
} | ||
} | ||
|
||
public static class TestFragment extends Fragment { | ||
|
||
@Nullable | ||
@Override | ||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | ||
return inflater.inflate(R.layout.recyclerview, container, false); | ||
} | ||
|
||
@Override | ||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | ||
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView); | ||
recyclerView.setAdapter(new TestAdapter()); | ||
recyclerView.addItemDecoration(new DividerItemDecoration(view.getContext(), DividerItemDecoration.VERTICAL)); | ||
} | ||
} | ||
|
||
private static class TestAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { | ||
|
||
@Override | ||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||
int padding = (int) TypedValue.applyDimension( | ||
TypedValue.COMPLEX_UNIT_DIP, 16, parent.getResources().getDisplayMetrics()); | ||
TextView textView = new TextView(parent.getContext()); | ||
textView.setPadding(padding, padding, padding, padding); | ||
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); | ||
|
||
return new RecyclerView.ViewHolder(textView) { | ||
}; | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { | ||
|
||
if (holder.itemView instanceof TextView) { | ||
((TextView) holder.itemView).setText(String.valueOf(position)); | ||
} | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return 100; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.simple; | ||
|
||
import android.os.Bundle; | ||
import android.support.v4.view.ViewPager; | ||
import android.support.v7.app.AppCompatActivity; | ||
|
||
import com.bottom.NavigationController; | ||
import com.bottom.PageNavigationView; | ||
import com.bottom.item.BaseTabItem; | ||
import com.simple.custom.OnlyIconItemView; | ||
import com.simple.custom.TestRepeatTab; | ||
import com.simple.other.MyViewPagerAdapter; | ||
|
||
public class Custom2Activity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.layout_horizontal); | ||
|
||
PageNavigationView tab = (PageNavigationView) findViewById(R.id.tab); | ||
|
||
NavigationController navigationController = tab.custom() | ||
.addItem(newItem_test(R.drawable.ic_restore_gray_24dp, R.drawable.ic_restore_teal_24dp)) | ||
.addItem(newItem(R.drawable.ic_favorite_gray_24dp, R.drawable.ic_favorite_teal_24dp)) | ||
.addItem(newItem(R.drawable.ic_nearby_gray_24dp, R.drawable.ic_nearby_teal_24dp)) | ||
.build(); | ||
|
||
ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager); | ||
viewPager.setAdapter(new MyViewPagerAdapter(getSupportFragmentManager(), navigationController.getItemCount())); | ||
|
||
//自动适配ViewPager页面切换 | ||
navigationController.setupWithViewPager(viewPager); | ||
} | ||
|
||
//创建一个Item | ||
private BaseTabItem newItem(int drawable, int checkedDrawable) { | ||
OnlyIconItemView onlyIconItemView = new OnlyIconItemView(this); | ||
onlyIconItemView.initialize(drawable, checkedDrawable); | ||
return onlyIconItemView; | ||
} | ||
|
||
//创建一个Item(测试重复点击的方法) | ||
private BaseTabItem newItem_test(int drawable, int checkedDrawable) { | ||
TestRepeatTab testRepeatTab = new TestRepeatTab(this); | ||
testRepeatTab.initialize(drawable, checkedDrawable); | ||
return testRepeatTab; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.simple; | ||
|
||
import android.graphics.Color; | ||
import android.os.Bundle; | ||
import android.support.v4.view.ViewPager; | ||
import android.support.v7.app.AppCompatActivity; | ||
|
||
import com.bottom.NavigationController; | ||
import com.bottom.PageNavigationView; | ||
import com.bottom.item.BaseTabItem; | ||
import com.bottom.item.NormalItemView; | ||
import com.simple.other.MyViewPagerAdapter; | ||
|
||
public class CustomActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.layout_horizontal); | ||
|
||
PageNavigationView tab = (PageNavigationView) findViewById(R.id.tab); | ||
|
||
NavigationController navigationController = tab.custom() | ||
.addItem(newItem(R.drawable.ic_restore_gray_24dp, R.drawable.ic_restore_teal_24dp, "Recents")) | ||
.addItem(newItem(R.drawable.ic_favorite_gray_24dp, R.drawable.ic_favorite_teal_24dp, "Favorites")) | ||
.addItem(newItem(R.drawable.ic_nearby_gray_24dp, R.drawable.ic_nearby_teal_24dp, "Nearby")) | ||
.build(); | ||
|
||
ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager); | ||
viewPager.setAdapter(new MyViewPagerAdapter(getSupportFragmentManager(), navigationController.getItemCount())); | ||
|
||
//自动适配ViewPager页面切换 | ||
navigationController.setupWithViewPager(viewPager); | ||
|
||
//设置消息数 | ||
navigationController.setMessageNumber(1, 8); | ||
|
||
//设置显示小圆点 | ||
navigationController.setHasMessage(0, true); | ||
} | ||
|
||
//创建一个Item | ||
private BaseTabItem newItem(int drawable, int checkedDrawable, String text) { | ||
NormalItemView normalItemView = new NormalItemView(this); | ||
normalItemView.initialize(drawable, checkedDrawable, text); | ||
normalItemView.setTextDefaultColor(Color.GRAY); | ||
normalItemView.setTextCheckedColor(0xFF009688); | ||
return normalItemView; | ||
} | ||
} |
Oops, something went wrong.