├── .gitignore ├── .idea ├── modules.xml └── runConfigurations.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── spikeking │ │ └── github │ │ └── com │ │ └── myapplication │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── spikeking │ │ │ └── github │ │ │ └── com │ │ │ └── myapplication │ │ │ ├── ImageAnimator.java │ │ │ ├── MainActivity.java │ │ │ ├── PagerChangeListener.java │ │ │ ├── SimpleAdapter.java │ │ │ └── SimpleFragment.java │ └── res │ │ ├── drawable-v21 │ │ ├── ic_menu_camera.xml │ │ ├── ic_menu_gallery.xml │ │ ├── ic_menu_manage.xml │ │ ├── ic_menu_send.xml │ │ ├── ic_menu_share.xml │ │ └── ic_menu_slideshow.xml │ │ ├── drawable │ │ ├── side_nav_bar.xml │ │ ├── taeyeon.png │ │ ├── tiffany.png │ │ └── yoona.png │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── app_bar_main.xml │ │ ├── content_main.xml │ │ ├── fragment_main.xml │ │ └── nav_header_main.xml │ │ ├── menu │ │ ├── activity_main_drawer.xml │ │ └── main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-v21 │ │ └── styles.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── drawables.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── spikeking │ └── github │ └── com │ └── myapplication │ └── ExampleUnitTest.java ├── appbar-anim.gif ├── appbar-demo.png ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | /.idea/misc.xml 7 | /.idea/gradle.xml 8 | .DS_Store 9 | /build 10 | /captures 11 | .idea 12 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AppBar 布局的使用方式 2 | 3 | AppBar的开发标准模板,Created by C.L. Wang 4 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion '27.0.3' 6 | 7 | defaultConfig { 8 | applicationId "spikeking.github.com.myapplication" 9 | minSdkVersion 17 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 | implementation fileTree(dir: 'libs', include: ['*.jar']) 24 | testImplementation 'junit:junit:4.12' 25 | implementation 'com.android.support:appcompat-v7:23.1.0' 26 | implementation 'com.android.support:design:23.1.0' 27 | implementation 'com.android.support:percent:23.1.0' 28 | implementation 'com.jakewharton:butterknife:7.0.1' 29 | compileOnly 'com.jakewharton:butterknife:7.0.1' 30 | annotationProcessor 'com.jakewharton:butterknife:7.0.1' 31 | } 32 | -------------------------------------------------------------------------------- /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 /Users/wangchenlong/Installations/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/spikeking/github/com/myapplication/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package spikeking.github.com.myapplication; 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 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/spikeking/github/com/myapplication/ImageAnimator.java: -------------------------------------------------------------------------------- 1 | package spikeking.github.com.myapplication; 2 | 3 | import android.support.annotation.DrawableRes; 4 | import android.util.Log; 5 | import android.view.View; 6 | import android.widget.ImageView; 7 | 8 | /** 9 | * 渐变的动画效果 10 | *

11 | * Created by wangchenlong on 15/11/9. 12 | */ 13 | public class ImageAnimator { 14 | 15 | private static final float FACTOR = 0.1f; // 移动距离 16 | 17 | private final SimpleAdapter mAdapter; // 适配器 18 | private final ImageView mTargetImage; // 原始图片的控件 19 | private final ImageView mOutgoingImage; // 渐变图片的控件 20 | 21 | private int mStartPosition; // 实际起始位置 22 | 23 | private int mMinPos; // 最小位置 24 | private int mMaxPos; // 最大位置 25 | 26 | public ImageAnimator(SimpleAdapter adapter, ImageView targetImage, ImageView outgoingImage) { 27 | mAdapter = adapter; 28 | mTargetImage = targetImage; 29 | mOutgoingImage = outgoingImage; 30 | } 31 | 32 | /** 33 | * 启动动画, 之后选择向前或向后滑动 34 | * 35 | * @param startPosition 起始位置 36 | * @param endPosition 终止位置 37 | */ 38 | public void start(int startPosition, int endPosition) { 39 | mStartPosition = startPosition; 40 | 41 | // 终止位置的图片 42 | @DrawableRes int incomeId = mAdapter.getDrawable(endPosition); 43 | 44 | // 原始图片 45 | mOutgoingImage.setImageDrawable(mTargetImage.getDrawable()); // 原始的图片 46 | 47 | // 起始图片 48 | mOutgoingImage.setTranslationX(0f); 49 | 50 | mOutgoingImage.setVisibility(View.VISIBLE); 51 | mOutgoingImage.setAlpha(1.0f); 52 | 53 | // 目标图片 54 | mTargetImage.setImageResource(incomeId); 55 | 56 | mMinPos = Math.min(startPosition, endPosition); 57 | mMaxPos = Math.max(startPosition, endPosition); 58 | } 59 | 60 | /** 61 | * 滑动结束的动画效果 62 | * 63 | * @param endPosition 滑动位置 64 | */ 65 | public void end(int endPosition) { 66 | @DrawableRes int incomeId = mAdapter.getDrawable(endPosition); 67 | mTargetImage.setTranslationX(0f); 68 | 69 | // 设置原始图片 70 | if (endPosition == mStartPosition) { 71 | mTargetImage.setImageDrawable(mOutgoingImage.getDrawable()); 72 | } else { 73 | mTargetImage.setImageResource(incomeId); 74 | mTargetImage.setAlpha(1f); 75 | mOutgoingImage.setVisibility(View.GONE); 76 | } 77 | } 78 | 79 | /** 80 | * 向前滚动, 比如0->1, offset滚动的距离(0->1), 目标渐渐淡出 81 | * 82 | * @param positionOffset 位置偏移 83 | */ 84 | public void forward(float positionOffset) { 85 | Log.e("DEBUG-WCL", "forward-positionOffset: " + positionOffset); 86 | int width = mTargetImage.getWidth(); 87 | mOutgoingImage.setTranslationX(-positionOffset * (FACTOR * width)); 88 | mTargetImage.setTranslationX((1 - positionOffset) * (FACTOR * width)); 89 | 90 | mTargetImage.setAlpha(positionOffset); 91 | } 92 | 93 | /** 94 | * 向后滚动, 比如1->0, offset滚动的距离(1->0), 目标渐渐淡入 95 | * 96 | * @param positionOffset 位置偏移 97 | */ 98 | public void backwards(float positionOffset) { 99 | Log.e("DEBUG-WCL", "backwards-positionOffset: " + positionOffset); 100 | int width = mTargetImage.getWidth(); 101 | mOutgoingImage.setTranslationX((1 - positionOffset) * (FACTOR * width)); 102 | mTargetImage.setTranslationX(-(positionOffset) * (FACTOR * width)); 103 | 104 | mTargetImage.setAlpha(1 - positionOffset); 105 | } 106 | 107 | // 判断位置是否在其中,用于停止动画 108 | public boolean isWithin(int position) { 109 | return position >= mMinPos && position < mMaxPos; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /app/src/main/java/spikeking/github/com/myapplication/MainActivity.java: -------------------------------------------------------------------------------- 1 | package spikeking.github.com.myapplication; 2 | 3 | import android.os.Bundle; 4 | import android.support.design.widget.NavigationView; 5 | import android.support.design.widget.TabLayout; 6 | import android.support.v4.view.GravityCompat; 7 | import android.support.v4.view.ViewPager; 8 | import android.support.v4.widget.DrawerLayout; 9 | import android.support.v7.app.ActionBarDrawerToggle; 10 | import android.support.v7.app.AppCompatActivity; 11 | import android.support.v7.widget.Toolbar; 12 | import android.view.Menu; 13 | import android.view.MenuItem; 14 | import android.widget.ImageView; 15 | 16 | import butterknife.Bind; 17 | import butterknife.ButterKnife; 18 | 19 | public class MainActivity extends AppCompatActivity 20 | implements NavigationView.OnNavigationItemSelectedListener { 21 | 22 | @Bind(R.id.main_vp_container) ViewPager mVpContainer; 23 | @Bind(R.id.toolbar_tl_tab) TabLayout mTlTab; 24 | @Bind(R.id.appbar_iv_outgoing) ImageView mIvOutgoing; 25 | @Bind(R.id.appbar_iv_target) ImageView mIvTarget; 26 | 27 | @Override 28 | protected void onCreate(Bundle savedInstanceState) { 29 | super.onCreate(savedInstanceState); 30 | setContentView(R.layout.activity_main); 31 | ButterKnife.bind(this); 32 | 33 | // 导航栏 34 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 35 | setSupportActionBar(toolbar); 36 | 37 | // 抽屉布局 38 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 39 | ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( 40 | this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); 41 | drawer.setDrawerListener(toggle); 42 | toggle.syncState(); 43 | 44 | // 抽屉布局中的导航布局 45 | NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); 46 | navigationView.setNavigationItemSelectedListener(this); 47 | 48 | // 设置ViewPager布局 49 | SimpleAdapter adapter = new SimpleAdapter(getSupportFragmentManager()); 50 | mVpContainer.setAdapter(adapter); 51 | mVpContainer.addOnPageChangeListener(PagerChangeListener.newInstance(adapter, mIvTarget, mIvOutgoing)); 52 | mTlTab.setupWithViewPager(mVpContainer); // 注意在Toolbar中关联ViewPager 53 | 54 | setTitle("Girls' Generation"); 55 | } 56 | 57 | @Override 58 | public void onBackPressed() { 59 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 60 | if (drawer.isDrawerOpen(GravityCompat.START)) { 61 | drawer.closeDrawer(GravityCompat.START); 62 | } else { 63 | super.onBackPressed(); 64 | } 65 | } 66 | 67 | @Override 68 | public boolean onCreateOptionsMenu(Menu menu) { 69 | // Inflate the menu; this adds items to the action bar if it is present. 70 | getMenuInflater().inflate(R.menu.main, menu); 71 | return true; 72 | } 73 | 74 | @Override 75 | public boolean onOptionsItemSelected(MenuItem item) { 76 | // Handle action bar item clicks here. The action bar will 77 | // automatically handle clicks on the Home/Up button, so long 78 | // as you specify a parent activity in AndroidManifest.xml. 79 | int id = item.getItemId(); 80 | 81 | //noinspection SimplifiableIfStatement 82 | if (id == R.id.action_settings) { 83 | return true; 84 | } 85 | 86 | return super.onOptionsItemSelected(item); 87 | } 88 | 89 | @SuppressWarnings("StatementWithEmptyBody") 90 | @Override 91 | public boolean onNavigationItemSelected(MenuItem item) { 92 | // Handle navigation view item clicks here. 93 | int id = item.getItemId(); 94 | 95 | if (id == R.id.nav_camera) { 96 | // Handle the camera action 97 | } else if (id == R.id.nav_gallery) { 98 | 99 | } else if (id == R.id.nav_slideshow) { 100 | 101 | } else if (id == R.id.nav_manage) { 102 | 103 | } else if (id == R.id.nav_share) { 104 | 105 | } else if (id == R.id.nav_send) { 106 | 107 | } 108 | 109 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 110 | drawer.closeDrawer(GravityCompat.START); 111 | return true; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /app/src/main/java/spikeking/github/com/myapplication/PagerChangeListener.java: -------------------------------------------------------------------------------- 1 | package spikeking.github.com.myapplication; 2 | 3 | import android.support.v4.view.ViewPager; 4 | import android.util.Log; 5 | import android.widget.ImageView; 6 | 7 | /** 8 | * ViewPager滑动页面监听 9 | *

10 | * Created by wangchenlong on 15/11/9. 11 | */ 12 | public class PagerChangeListener implements ViewPager.OnPageChangeListener { 13 | private ImageAnimator mImageAnimator; // 图片动画器 14 | 15 | private int mCurrentPosition; 16 | private int mFinalPosition; 17 | private boolean mIsScrolling = false; 18 | 19 | private PagerChangeListener(ImageAnimator imageAnimator) { 20 | mImageAnimator = imageAnimator; 21 | } 22 | 23 | public static PagerChangeListener newInstance(SimpleAdapter adapter, ImageView originImage, ImageView outgoingImage) { 24 | ImageAnimator imageAnimator = new ImageAnimator(adapter, originImage, outgoingImage); 25 | return new PagerChangeListener(imageAnimator); 26 | } 27 | 28 | /** 29 | * 滑动监听 30 | * 31 | * @param position 当前位置 32 | * @param positionOffset 偏移距离[当前值+-1] 33 | * @param positionOffsetPixels 偏移像素 34 | */ 35 | @Override 36 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { 37 | Log.e("DEBUG-WCL", "position: " + position + ", positionOffset: " + positionOffset); 38 | 39 | // 以前滑动, 现在终止 40 | if (isFinishedScrolling(position, positionOffset)) { 41 | finishScroll(position); 42 | } 43 | 44 | // 判断前后滑动是否开始 45 | if (isStartingScrollToPrevious(position, positionOffset)) { 46 | startScroll(position); 47 | } else if (isStartingScrollToNext(position, positionOffset)) { 48 | startScroll(position + 1); // 向后滚动需要加1 49 | } 50 | 51 | // 向后滚动 52 | if (isScrollingToNext(position, positionOffset)) { 53 | mImageAnimator.forward(positionOffset); 54 | } else if (isScrollingToPrevious(position, positionOffset)) { // 向前滚动 55 | mImageAnimator.backwards(positionOffset); 56 | } 57 | } 58 | 59 | @Override 60 | public void onPageScrollStateChanged(int state) { 61 | //NO-OP 62 | } 63 | 64 | @Override 65 | public void onPageSelected(int position) { 66 | //NO-OP 67 | } 68 | 69 | /** 70 | * 终止滑动 71 | * 滑动 && [偏移是0&&滑动终点] || 动画之中 72 | * 73 | * @param position 位置 74 | * @param positionOffset 偏移量 75 | * @return 终止滑动 76 | */ 77 | private boolean isFinishedScrolling(int position, float positionOffset) { 78 | return mIsScrolling && (positionOffset == 0f && position == mFinalPosition) || !mImageAnimator.isWithin(position); 79 | } 80 | 81 | /** 82 | * 从静止到开始滑动, 下一个 83 | * 未滑动 && 位置是当前位置 && 偏移量不是0 84 | * 85 | * @param position 位置 86 | * @param positionOffset 偏移量 87 | * @return 是否 88 | */ 89 | private boolean isStartingScrollToNext(int position, float positionOffset) { 90 | return !mIsScrolling && position == mCurrentPosition && positionOffset != 0f; 91 | } 92 | 93 | /** 94 | * 从静止到开始滑动, 前一个[position-1] 95 | * 96 | * @param position 位置 97 | * @param positionOffset 偏移量 98 | * @return 是否 99 | */ 100 | private boolean isStartingScrollToPrevious(int position, float positionOffset) { 101 | return !mIsScrolling && position != mCurrentPosition && positionOffset != 0f; 102 | } 103 | 104 | /** 105 | * 开始滚动, 向后 106 | * 107 | * @param position 位置 108 | * @param positionOffset 偏移 109 | * @return 是否 110 | */ 111 | private boolean isScrollingToNext(int position, float positionOffset) { 112 | return mIsScrolling && position == mCurrentPosition && positionOffset != 0f; 113 | } 114 | 115 | /** 116 | * 开始滚动, 向前 117 | * 118 | * @param position 位置 119 | * @param positionOffset 偏移 120 | * @return 是否 121 | */ 122 | private boolean isScrollingToPrevious(int position, float positionOffset) { 123 | return mIsScrolling && position != mCurrentPosition && positionOffset != 0f; 124 | } 125 | 126 | /** 127 | * 开始滑动 128 | * 滚动开始, 结束位置是position[前滚时position会自动减一], 动画从当前位置到结束位置. 129 | * 130 | * @param position 滚动结束之后的位置 131 | */ 132 | private void startScroll(int position) { 133 | mIsScrolling = true; 134 | mFinalPosition = position; 135 | 136 | // 开始滚动动画 137 | mImageAnimator.start(mCurrentPosition, position); 138 | } 139 | 140 | /** 141 | * 如果正在滚动, 结束时, 固定position位置, 停止滚动, 调动截止动画 142 | * 143 | * @param position 位置 144 | */ 145 | private void finishScroll(int position) { 146 | if (mIsScrolling) { 147 | mCurrentPosition = position; 148 | mIsScrolling = false; 149 | mImageAnimator.end(position); 150 | } 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /app/src/main/java/spikeking/github/com/myapplication/SimpleAdapter.java: -------------------------------------------------------------------------------- 1 | package spikeking.github.com.myapplication; 2 | 3 | import android.support.annotation.DrawableRes; 4 | import android.support.v4.app.Fragment; 5 | import android.support.v4.app.FragmentManager; 6 | import android.support.v4.app.FragmentPagerAdapter; 7 | 8 | /** 9 | * ViewPager的适配器 10 | *

11 | * Created by wangchenlong on 15/11/9. 12 | */ 13 | public class SimpleAdapter extends FragmentPagerAdapter { 14 | 15 | // 展示信息 16 | private static final Section[] SECTIONS = { 17 | new Section("Tiffany", R.drawable.tiffany), 18 | new Section("Taeyeon", R.drawable.taeyeon), 19 | new Section("Yoona", R.drawable.yoona) 20 | }; 21 | 22 | // 默认构造器 23 | public SimpleAdapter(FragmentManager fm) { 24 | super(fm); 25 | } 26 | 27 | // 根据不同位置(position),显示不同的Fragment 28 | @Override 29 | public Fragment getItem(int position) { 30 | return SimpleFragment.newInstance(position); 31 | } 32 | 33 | // 子页面Fragment的个数 34 | @Override 35 | public int getCount() { 36 | return SECTIONS.length; 37 | } 38 | 39 | // 每个页面的标题,当ToolBar联动时,即为Tab的标题 40 | @Override 41 | public CharSequence getPageTitle(int position) { 42 | if (position >= 0 && position < SECTIONS.length) { 43 | return SECTIONS[position].getTitle(); 44 | } 45 | return null; 46 | } 47 | 48 | // 图片接口 49 | public @DrawableRes int getDrawable(int position) { 50 | if (position >= 0 && position < SECTIONS.length) { 51 | return SECTIONS[position].getDrawable(); 52 | } 53 | return -1; 54 | } 55 | 56 | // 存储类 57 | private static final class Section { 58 | private final String mTitle; // 标题 59 | private final @DrawableRes int mDrawable; // 图片 60 | 61 | public Section(String title, int drawable) { 62 | mTitle = title; 63 | mDrawable = drawable; 64 | } 65 | 66 | public String getTitle() { 67 | return mTitle; 68 | } 69 | 70 | public int getDrawable() { 71 | return mDrawable; 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /app/src/main/java/spikeking/github/com/myapplication/SimpleFragment.java: -------------------------------------------------------------------------------- 1 | package spikeking.github.com.myapplication; 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 | import butterknife.Bind; 12 | import butterknife.ButterKnife; 13 | 14 | /** 15 | * 简单的Fragment 16 | *

17 | * Created by wangchenlong on 15/11/9. 18 | */ 19 | public class SimpleFragment extends Fragment { 20 | private static final String ARG_SELECTION_NUM = "arg_selection_num"; // 参数的Tag 21 | 22 | // 显示的文本信息 23 | private static final int[] TEXTS = { 24 | R.string.tiffany_text, 25 | R.string.taeyeon_text, 26 | R.string.yoona_text 27 | }; 28 | 29 | @Bind(R.id.main_tv_text) TextView mTvText; 30 | 31 | public SimpleFragment() { 32 | } 33 | 34 | /** 35 | * 通过静态接口创建Fragment,规范参数的使用 36 | * 37 | * @param selectionNum 参数 38 | * @return 创建的Fragment 39 | */ 40 | public static SimpleFragment newInstance(int selectionNum) { 41 | SimpleFragment simpleFragment = new SimpleFragment(); 42 | Bundle args = new Bundle(); 43 | args.putInt(ARG_SELECTION_NUM, selectionNum); 44 | simpleFragment.setArguments(args); 45 | return simpleFragment; 46 | } 47 | 48 | 49 | @Nullable 50 | @Override 51 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 52 | View view = inflater.inflate(R.layout.fragment_main, container, false); 53 | ButterKnife.bind(this, view); 54 | return view; 55 | } 56 | 57 | @Override 58 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 59 | super.onViewCreated(view, savedInstanceState); 60 | mTvText.setText(TEXTS[getArguments().getInt(ARG_SELECTION_NUM)]); // 设置文本信息 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_camera.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_gallery.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_manage.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_send.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_share.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_slideshow.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/side_nav_bar.xml: -------------------------------------------------------------------------------- 1 | 3 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/taeyeon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpikeKing/TestAppBar/a476dc3a5faeb9cf1f6289e3f08d6fca4127e743/app/src/main/res/drawable/taeyeon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/tiffany.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpikeKing/TestAppBar/a476dc3a5faeb9cf1f6289e3f08d6fca4127e743/app/src/main/res/drawable/tiffany.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/yoona.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpikeKing/TestAppBar/a476dc3a5faeb9cf1f6289e3f08d6fca4127e743/app/src/main/res/drawable/yoona.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 17 | 18 | 19 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/layout/app_bar_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 17 | 18 | 19 | 27 | 28 | 34 | 35 | 44 | 45 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 67 | 73 | 74 | 75 | 76 | 77 | 83 | 84 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 15 | 16 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/layout/nav_header_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 20 | 21 | 27 | 28 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/menu/activity_main_drawer.xml: -------------------------------------------------------------------------------- 1 | 2 |

3 | 4 | 5 | 9 | 13 | 17 | 21 | 22 | 23 | 24 | 25 | 29 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /app/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 5 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpikeKing/TestAppBar/a476dc3a5faeb9cf1f6289e3f08d6fca4127e743/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpikeKing/TestAppBar/a476dc3a5faeb9cf1f6289e3f08d6fca4127e743/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpikeKing/TestAppBar/a476dc3a5faeb9cf1f6289e3f08d6fca4127e743/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpikeKing/TestAppBar/a476dc3a5faeb9cf1f6289e3f08d6fca4127e743/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpikeKing/TestAppBar/a476dc3a5faeb9cf1f6289e3f08d6fca4127e743/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | > 2 | 3 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FF1493 4 | #FF1493 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 160dp 5 | 6 | 16dp 7 | 16dp 8 | 16dp 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/drawables.xml: -------------------------------------------------------------------------------- 1 | 2 | @android:drawable/ic_menu_camera 3 | @android:drawable/ic_menu_gallery 4 | @android:drawable/ic_menu_slideshow 5 | @android:drawable/ic_menu_manage 6 | @android:drawable/ic_menu_share 7 | @android:drawable/ic_menu_send 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | My Application 3 | 4 | Open navigation drawer 5 | Close navigation drawer 6 | 7 | Settings 8 | 黄美英(Tiffany),1989年8月1日出生于美国加利福尼亚州旧金山市,韩国女歌手、主持人,女子演唱团体少女时代成员之一。2004年,黄美英在洛杉矶参加“S.M. casting System”选秀后进入韩国SM娱乐有限公司成为旗下练习生。2007年8月以演唱团体少女时代正式出道,担任主唱以及副领舞的职务。2009年凭借歌曲《By Myself》入围“第11届Mnet亚洲音乐大奖”最佳OST奖提名。 9 | 金泰妍(Taeyeon),1989年3月9日出生于韩国全罗北道全州市,韩国女歌手、主持人,女子演唱团体少女时代成员之一。2004年在第八届SM青少年选拔大赛歌王中夺得第一名,进入韩国SM娱乐有限公司开始练习生生涯。2007年8月以演唱团体少女时代成员身份正式出道。2008年为韩国KBS电视台电视剧《快刀洪吉童》演唱主题曲《如果》;同年12月凭借歌曲《听得见吗》获得第23届韩国金唱片大奖人气奖。2012年与黄美英、徐珠贤组成了少女时代的小分队组合“TaeTiSeo”。 10 | 林允儿(Yoona),1990年5月30日出生于韩国首尔,韩国女歌手、演员、主持人,女子演唱团体少女时代成员之一。2002年,林允儿被韩国SM娱乐有限公司发掘,正式进入SM公司成为旗下练习生。2007年8月5日以演唱团体少女时代正式出道。2008年在电视连续剧《你是我的命运》担任女主角,凭借该剧获得第45届百想艺术大赏最佳新人女演员奖。2009年参演电视剧《乞丐变王子》;同年凭借电视剧《你是我的命运》获得百想艺术大奖最佳新人女演员奖。 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 |