[英]Animation like switching accounts in Gmail App
使用帶有布局的動畫效果,並根據需要制作它。 我建議你按照對我有用的教程,我將它用於動畫。
動畫導航示例
https://github.com/mxn21/FlowingDrawer
動畫的按鈕效果
其他有用
https://github.com/XXApple/AndroidLibs/blob/master/%E5%B8%83%E5%B1%80Layout/README.md
它是Ravi Bro的古老但常青的例子。
http://www.androidhive.info/2013/06/android-working-with-xml-animations/
正如我發現這個鏈接。 : https : //github.com/HeinrichReimer/material-drawer 。
在此鏈接中, NavigationDrawer
演示使用Switch Account
技術,您需要更改帳戶。
為此,您可以通過單擊Small round corner
選擇您的帳戶,如在屏幕截圖(+2)
,右側打開DropDown
,您可以選擇您必須去的帳戶。
repositories {
// ...
maven { url 'https://jitpack.io' }
}
dependencies {
compile 'com.heinrichreimersoftware:material-drawer:2.3.2'
}
第1步:讓您的Activity擴展DrawerActivity:
public class MainActivity extends DrawerActivity {}
第2步:設置您的內容:
setContentView(R.layout.activity_main);
第3步:設置個人資料:
drawer.setProfile(
new DrawerProfile()
.setRoundedAvatar((BitmapDrawable)getResources().getDrawable(R.drawable.profile_avatar))
.setBackground(getResources().getDrawable(R.drawable.profile_cover))
.setName(getString(R.string.profile_name))
.setDescription(getString(R.string.profile_description))
.setOnProfileClickListener(new DrawerProfile.OnProfileClickListener() {
@Override
public void onClick(DrawerProfile drawerProfile, long id) {
Toast.makeText(MainActivity.this, "Clicked profile #" + id, Toast.LENGTH_SHORT).show();
}
})
);
第4步:填充抽屜列表:
drawer.addItem(
new DrawerItem()
.setImage(getResources().getDrawable(R.drawable.ic_first_item))
.setTextPrimary(getString(R.string.title_first_item))
.setTextSecondary(getString(R.string.description_first_item))
.setOnItemClickListener(new DrawerItem.OnItemClickListener() {
@Override
public void onClick(DrawerItem drawerItem, long id, int position) {
Toast.makeText(MainActivity.this, "Clicked first item #" + id, Toast.LENGTH_SHORT).show();
}
})
);
drawer.addDivider();
drawer.addItem(
new DrawerItem()
.setImage(getResources().getDrawable(R.drawable.ic_second_item))
.setTextPrimary(getString(R.string.title_second_item))
.setOnItemClickListener(new DrawerItem.OnItemClickListener() {
@Override
public void onClick(DrawerItem drawerItem, long id, int position) {
Toast.makeText(MainActivity.this, "Clicked second item #" + id, Toast.LENGTH_SHORT).show();
}
})
);
第5步:為您的主題添加actionBarStyle:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/color_primary</item>
<item name="colorPrimaryDark">@color/color_primary_dark</item>
<item name="colorAccent">@color/color_accent</item>
<item name="actionBarStyle">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
</style>
步驟6(可選):更改抽屜主題:
抽屜根據您選擇的應用主題獲取主題,但您也可以修改它。
setDrawerTheme(
new DrawerTheme(this)
.setBackgroundColorRes(R.color.background)
.setTextColorPrimaryRes(R.color.primary_text)
.setTextColorSecondaryRes(R.color.secondary_text)
.setTextColorPrimaryInverseRes(R.color.primary_text_inverse)
.setTextColorSecondaryInverseRes(R.color.secondary_text_inverse)
.setHighlightColorRes(R.color.highlight)
);
步驟7(可選):設置您自己的工具欄:
您可以像使用ActionBarActivity一樣設置自己的工具欄。
setSupportActionBar(toolbar);
希望這能幫助你快樂編碼......
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.