Morphing-Material-Dialogs
介绍:
打开动画morphing 动效的Material dialog
运行效果:
使用说明:
在 root (project) 的 build.gradle中添加:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
在app的 build.gradle中添加:
dependencies {
implementation 'com.github.AdityaAnand1:Morphing-Material-Dialogs:0.0.1-alpha2'
}
添加design support library:
dependencies {
implementation "com.android.support:design:26.01"
}
在 styles.xml中,重写MorphDialog.Base theme(至少一个,如果想同时支持 light and 和 dark主题则是两个)
<style name="MorphDialog.Custom.Light" parent="MorphDialog.Base.Light">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
</style>
<style name="MorphDialog.Custom.Dark" parent="MorphDialog.Base.Dark">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
</style>
在app的manifest文件中,添加下面的代码(至少一个,如果想同时支持 light and 和 dark主题则是两个)
<activity
android:name="in.adityaanand.morphdialog.MorphDialogActivity"
android:theme="@style/MorphDialog.Custom.Light">
</activity>
<activity
android:name="in.adityaanand.morphdialog.MorphDialogActivityDark"
android:theme="@style/MorphDialog.Custom.Dark">
</activity>
这个library是afollestad/material-dialogs的子集。目前可以设置title, content, 确定按钮文字和取消按钮文字。
new MorphDialog.Builder(this, fabView)
.title("Title")
.content("This is a sentence. Here is another one.")
.positiveText(R.string.ok)
.useDarkTheme(true) //optional, default is false
.show();
比如,假设你的activity中有一个 floating action button
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="morph"/>
那么 morph() 就是这样的:
public void morph(View view) {
new MorphDialog.Builder(this, (FloatingActionButton) view)
.title("Title")
.content("This is a sentence. Here is another one.")
.show();
}
已下载
0