在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):heinrichreimer/material-drawer开源软件地址(OpenSource Url):https://github.com/heinrichreimer/material-drawer开源编程语言(OpenSource Language):Java 100.0%开源软件介绍(OpenSource Introduction):material-drawerCustom drawer implementation for Material design apps. DemoA demo app is available on Google Play: Screenshots
Dependencymaterial-drawer is available on jitpack.io Gradle dependency: repositories {
// ...
maven { url 'https://jitpack.io' }
} dependencies {
compile 'com.heinrichreimersoftware:material-drawer:2.3.3'
} Get the latest dependency at jitpack.io. How-To-UseStep 1: Let your public class MainActivity extends DrawerActivity {} Step 2: Set your content: setContentView(R.layout.activity_main); Step 3: Add a profile: addProfile(
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();
}
})
); Step 4: Populate your drawer list: 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();
}
})
);
addDivider();
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();
}
})
); Step 5: Add <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> Step 6 (Optional): Change the drawer theme: The drawer gets themed based on your selected app theme but you can also modify it. 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)
); Step 7 (Optional): Set your own You can set your own setSupportActionBar(toolbar); Pro Tip: Lollipop status barStep 1: Make your status bar transparent: <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style> That's it! material-drawer takes care of the rest.
Info: |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论