android-snackbar

Snackbar is not dismissing on swipe

旧街凉风 提交于 2019-12-05 01:46:52
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 activity's XML layout. Snackbar needs a CoordinatorLayout as its root layout or some where on top of it,

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

孤人 提交于 2019-12-04 18:53:17
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" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent">

How to push up an existing view when snackbar is displayed?

岁酱吖の 提交于 2019-12-04 12:14:08
问题 This is my attempt to push the "NEXT" button upwards when the snackbar is visible: As you can see, it doesn't work as planned. It appears as if the textview was pushed up and behind the RelativeLayout and then reappears when the snackbar disappears. Instead, what I want is the textview to appear pushed up (so it is above the snackbar ) and then come back down when the snackbar disappears. I have also created a small github repo to demonstrate this: https://github.com/Winghin2517/TestFabMotion

(Collapsing)Toolbar title resets its position after Snackbar appearance

ε祈祈猫儿з 提交于 2019-12-04 05:43:37
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: <CoordinatorLayout> <AppBarLayout> <CollapsingToolbarLayout> <Toolbar /> <TabLayout /> </CollapsingToolbarLayout>

Snackbar with CoordinatorLayout disable dismiss

无人久伴 提交于 2019-12-04 04:02:12
I am using the support FloatingActionButton Snackbar CoordinatorLayout I need the CoordinatorLayout so that if SnackBar is shown the FloatingActionButton moves up to make room for the Snackbar. For better understanding check this video . I am using SnackBar for double-back to exit the application, but the SnackBar can be dismissed. Is there a way to disable the dismiss on the SnackBar? Snackbar snackbar = Snackbar.make(view, R.string.press_back_again_to_exit, Snackbar.LENGTH_SHORT); snackbar.setAction(R.string.ok, new View.OnClickListener() { @Override public void onClick(View v) { } });

Can I display material design Snackbar in dialog?

萝らか妹 提交于 2019-12-04 03:05:43
问题 I am developing an android application. In that I want to display material design Snackbar in dialog. Is it possible? If yes then how? Please help me. Thanks. 回答1: It's definitely possible, you just have to pass the View of the Dialog to the SnackBar . Example AlertDialog.Builder mAlertDialogBuilder = new AlertDialog.Builder(this); LayoutInflater inflater = this.getLayoutInflater(); // inflate the custom dialog view final View mDialogView = inflater.inflate(R.layout.dialog_layout, null); //

Style SnackBar in theme app

烈酒焚心 提交于 2019-12-03 23:33:36
问题 I need help. How can I change the design of the text in snackbar in styles app? The change in the code does not interest me. I found the following code. But it is not working for me. Why is that? My theme is derived from @style/Theme.AppCompat.Light.DarkActionBar". I would be very grateful for the help. <style name="TextAppearance.Design.Snackbar.Message" parent="android:TextAppearance"> <item name="android:textSize">10sp</item> <item name="android:textColor">#FEFEFE</item> </style> <style

Snackbar action text color not changing

落花浮王杯 提交于 2019-12-03 22:04:20
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(); The argument of setActionTextColor is the int that represents the color, not the resource ID. Instead of this: .setActionTextColor(R.color.yellow) try: .setActionTextColor(Color.YELLOW) If you want to use resources anyway, try: .setActionTextColor

Snack bar not displayed

自作多情 提交于 2019-12-03 14:19:13
I'm inheriting from BaseActivity for all the other activities. public class BaseActivity extends AppCompatActivity { public static CoordinatorLayout coordinatorLayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_base); coordinatorLayout = (CoordinatorLayout) findViewById(R.id .coordinatorLayout1); } } activity_base.xml <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com

AdView and FloatingActionButton overlap while using CoordinatorLayout

ε祈祈猫儿з 提交于 2019-12-03 12:13:34
问题 After incorporating the new CoordinatorLayout in one of my layouts, I have an issue with Adview s overlapping with FloatingActionButton . <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/main_content" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width=