android-snackbar

Snackbar is not dismissing on swipe

一世执手 提交于 2019-12-10 02:58:24
问题 i have a snackbar in my appcompat activity. It has a button OK which dismiss the snackbar.It is working perfact. but i can't dismiss the snackbar on swipe(left to right). Following is my code for snackbar.... final Snackbar snackbar = Snackbar .make(view, "Error Message", Snackbar.LENGTH_INDEFINITE); snackbar.setAction("OK", new View.OnClickListener() { @Override public void onClick(View view) { snackbar.dismiss(); } }); snackbar.show(); Edit 1 I have Relative layout as parent layout in my

(Collapsing)Toolbar title resets its position after Snackbar appearance

谁都会走 提交于 2019-12-09 18:14:01
问题 I have a layout with CollapsingToolbarLayout and CoordinatorLayout as root element. Whenever a Snackbar is shown in the activity the title of the toolbar resets its position to the default expanded title position of the CollapsingToolbar even if the toolbar is not (fully) expanded. The second picture shows that the title is fixed no matter if the toolbar expands or not. The result is the same when I call snackbar.show() in activity or fragment . My layout structure looks like this:

Snackbar and CollapsingToolbarLayout with TranslucentNavigation

为君一笑 提交于 2019-12-08 07:35:30
I have Created an app with Scrolling Activity from the Android Studio Templets to test my coding of my main App affects that behavior or not, so I have just add to the code : <item name="android:windowTranslucentNavigation" tools:targetApi="kitkat">true</item> that shows the Snackbar behind the navigation bar as this screenshot (PS : I am using Xstane for redesigning my Navigation bar on my mobile but I think that does not affect the code cuz i have tried TranslucentNavigation with Snackbar Without CollapsingToolbarLayout and that works well) the App is supporting windowTranslucentNavigation

How to align message textview to the center in snackbar?

不羁岁月 提交于 2019-12-08 02:41:27
问题 How to align message textview to the center Horizontally in snackbar in android? 回答1: Below is a sample, for making the Snackbar Text center horizontal Snackbar snackbar = Snackbar.make(findViewById(R.id.coordinatorLayout), "Hello", Snackbar.LENGTH_SHORT); snackbar.show(); View view = snackbar.getView(); TextView txtv = (TextView) view.findViewById(android.support.design.R.id.snackbar_text); txtv.setGravity(Gravity.CENTER_HORIZONTAL); 回答2: Try to set both textAlignment and Gravity to the

Unable to show Snackbar from PreferenceFragment

倾然丶 夕夏残阳落幕 提交于 2019-12-07 14:56:07
问题 I want to use Snackbar onSharedPreferenceChange() inside my PreferenceFragment hosted by a Activity. preference.xml <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:key="ll_main"> <PreferenceCategory android:title="@string/push_notification"> <SwitchPreference android:title="@string/transectional_notification" android:key="trans_not" android:defaultValue="true" android:summary="@string/get_notified_about_any_changes

Match parent for width of ImageView in snackbar with custom view in Android is not working

守給你的承諾、 提交于 2019-12-06 13:45:37
问题 I am developing an Android app. In my app, I am using snackbar with custom view. My custom view has only child view. That is an image view. Showing custom view with snack bar is OK. But the problem is with the sizing the ImageView in the snack bar. I want to set it match parent for with. But width is not match to the width of snackbar. This is my custom view layout for snack bar <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

How to align message textview to the center in snackbar?

我与影子孤独终老i 提交于 2019-12-06 11:58:23
How to align message textview to the center Horizontally in snackbar in android? Below is a sample, for making the Snackbar Text center horizontal Snackbar snackbar = Snackbar.make(findViewById(R.id.coordinatorLayout), "Hello", Snackbar.LENGTH_SHORT); snackbar.show(); View view = snackbar.getView(); TextView txtv = (TextView) view.findViewById(android.support.design.R.id.snackbar_text); txtv.setGravity(Gravity.CENTER_HORIZONTAL); Try to set both textAlignment and Gravity to the Gravity.CENTER_HORIZONTAL snackTextView.setGravity(Gravity.CENTER_HORIZONTAL); snackTextView.setTextAlignment(Gravity

Unable to show Snackbar from PreferenceFragment

隐身守侯 提交于 2019-12-05 20:43:51
I want to use Snackbar onSharedPreferenceChange() inside my PreferenceFragment hosted by a Activity. preference.xml <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:key="ll_main"> <PreferenceCategory android:title="@string/push_notification"> <SwitchPreference android:title="@string/transectional_notification" android:key="trans_not" android:defaultValue="true" android:summary="@string/get_notified_about_any_changes_related_to_your_transections"/> <SwitchPreference android:title="@string/promotional_notification"

How to use Snackbar without support library?

痞子三分冷 提交于 2019-12-05 11:46:27
I am developing an Android app which doesn't require backward compatibility. Target SDK version is 22 as of now. I am using native Activity and Fragment and application theme is android:Theme.Material.Light. My problem is that I'm not able to use Snackbar with the existing setup, it throws exceptions like android.view.InflateException: Binary XML file line #18: Error inflating class android.support.design.widget.Snackbar$SnackbarLayout E/AndroidRuntime(19107): at android.view.LayoutInflater.createView(LayoutInflater.java:640) E/AndroidRuntime(19107): at android.view.LayoutInflater

Snackbar action text color not changing

青春壹個敷衍的年華 提交于 2019-12-05 08:28:10
问题 I want to change the action text color for my snackbar, but it is not working for some reason. I use the following code to display a snackbar: Snackbar.make(findViewById(R.id.root), "text", Snackbar.LENGTH_LONG).setActionTextColor(R.color.yellow).setAction("OK", new View.OnClickListener() { @Override public void onClick(View view) { } }).show(); 回答1: The argument of setActionTextColor is the int that represents the color, not the resource ID. Instead of this: .setActionTextColor(R.color