android-snackbar

Testing Snackbar show with Espresso

℡╲_俬逩灬. 提交于 2019-12-03 11:33:27
问题 Is there a way to test using Espresso that the snackbar shows up with the right text? I have a simple call to create a snackbar Snackbar.make(mView, "My text", Snackbar.LENGTH_LONG).show(); I have tried this without luck onView(withText("My text")).inRoot(withDecorView(not(is(mActivityRule.getActivity().getWindow().getDecorView())))).check(matches(isDisplayed())); 回答1: This worked for me, please try. onView(allOf(withId(android.support.design.R.id.snackbar_text), withText("My text"))) .check

How to move a view above Snackbar just like FloatingButton

柔情痞子 提交于 2019-12-03 03:30:13
问题 I got a linear layout that I want to move up when a Snackbar appears. I saw many examples how to do this with FloatingButton, but what about a regular view? 回答1: You need to add a behaviour to your LinearLayout and embed it in a CoordinatorLayout. You might want to read this: http://alisonhuang-blog.logdown.com/posts/290009-design-support-library-coordinator-layout-and-behavior 回答2: I'm going to elaborate on the approved answer because I think there's a slightly simpler implementation than

AdView and FloatingActionButton overlap while using CoordinatorLayout

拈花ヽ惹草 提交于 2019-12-03 02:57:17
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="match_parent" android:layout_height="wrap_content" android:theme="@style/ThemeOverlay.AppCompat.Dark

How to set support library snackbar text color to something other than android:textColor?

我怕爱的太早我们不能终老 提交于 2019-12-03 02:06:50
问题 So I've started using the new Snackbar in the Design Support Library, but I found that when you define "android:textColor" in your theme, it applies to the text color of the snackbar. This is obviously a problem if your primary text color is dark. Does anyone know a way around this or have advice for how I should color my text? EDIT January 2017: (Post-Answer) While there are some custom solutions to fix the problem below, it's probably good to provide the correct way to theme Snackbars.

Testing Snackbar show with Espresso

爱⌒轻易说出口 提交于 2019-12-03 01:04:46
Is there a way to test using Espresso that the snackbar shows up with the right text? I have a simple call to create a snackbar Snackbar.make(mView, "My text", Snackbar.LENGTH_LONG).show(); I have tried this without luck onView(withText("My text")).inRoot(withDecorView(not(is(mActivityRule.getActivity().getWindow().getDecorView())))).check(matches(isDisplayed())); ksarmalkar This worked for me, please try. onView(allOf(withId(android.support.design.R.id.snackbar_text), withText("My text"))) .check(matches(isDisplayed())); If you use AndroidX, please use the following: onView(withId(com.google

How to move a view above Snackbar just like FloatingButton

心不动则不痛 提交于 2019-12-02 17:01:49
I got a linear layout that I want to move up when a Snackbar appears. I saw many examples how to do this with FloatingButton, but what about a regular view? You need to add a behaviour to your LinearLayout and embed it in a CoordinatorLayout. You might want to read this: http://alisonhuang-blog.logdown.com/posts/290009-design-support-library-coordinator-layout-and-behavior Travis Castillo I'm going to elaborate on the approved answer because I think there's a slightly simpler implementation than that article provides. I wasn't able to find a built-in behavior that handles a generic moving of

Android: Multiple snackbars in separate Fragments (ViewPager)

痞子三分冷 提交于 2019-12-01 15:33:10
问题 I have a viewpager, with a few fragments of course. Each of these fragments have CoordinatorLayout as parent. I'm showing a snackbar for something. The problem is, if Fragment A shows a snackbar it's fine, but if it's adjacent fragment B also shows a snackbar the snackbar in fragment A automatically hides. Since viewpager adjacent fragments are preloaded, it's a visible issue. Any workaround? Or am I doing it wrong? 回答1: There is a few problems with snackbar in multiple Fragments in ViewPager

Move cardview on Snackbar - Co-ordinator layout

▼魔方 西西 提交于 2019-12-01 11:41:45
问题 I have a custom textview in a cardview at the bottom of the screen and using snackbar to display error messages on logging in. Now when the snackbar shows, the sign up textview should move up. I have tried using co-ordinator layout but it does not work. This is the image 回答1: You need to implement a layout behavior for your View and reference it from your layout xml file. It is simple to implement your own layout behavior. In your case, you only need to set the translation y of your view when

Android floating action button not returning to initial position

放肆的年华 提交于 2019-12-01 08:52:28
If the FAB (Floating Action Button) hides before a snackbar appears (in CoordinatorLayout) then the next time I show the FAB it is drawn in the old position (not moved down to the original position). If the FAB is visible when the snackbar dissapears, then everything is working as expected. Did I miss something or is it a bug? UPD: As requested, here is a minimal example. I will put most important bits here, and a fully working example can be found on my github This is just a very slightly modified example from Android template Activity project. activity_main.xml : <?xml version="1.0" encoding

Android floating action button not returning to initial position

狂风中的少年 提交于 2019-12-01 07:39:36
问题 If the FAB (Floating Action Button) hides before a snackbar appears (in CoordinatorLayout) then the next time I show the FAB it is drawn in the old position (not moved down to the original position). If the FAB is visible when the snackbar dissapears, then everything is working as expected. Did I miss something or is it a bug? UPD: As requested, here is a minimal example. I will put most important bits here, and a fully working example can be found on my github This is just a very slightly