Created
August 15, 2016 14:37
-
-
Save Hackforid/f0d07e642f918429d221efc15e2e8f32 to your computer and use it in GitHub Desktop.
Google Support Lib那些坑
This file contains hidden or 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
/** | |
* 解决Snackbar只能使用RootView的问题 防止Fragment切换后Snackbar依旧显示 | |
*/ | |
fun makeSnackbar(parent: ViewParent, text: CharSequence, duration: Int) : Snackbar { | |
val constructor = Snackbar::class.java.getDeclaredConstructor(ViewGroup::class.java) | |
constructor.isAccessible = true | |
val snackbar = constructor.newInstance(parent) | |
snackbar.setText(text) | |
snackbar.duration = duration | |
return snackbar | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment