How can you adjust Android SnackBar to a specific position on screen

It is possible to set the location that the Snackbar is displayed by positioning a android.support.design.widget.CoordinatorLayout within your existing Activity layout. For example, say your existing layout is a RelativeLayout you could add a CoordinatorLayout as follows: <android.support.design.widget.CoordinatorLayout android:layout_width=”match_parent” android:layout_height=”200dp” android:id=”@+id/myCoordinatorLayout” android:layout_alignParentTop=”true” android:layout_alignParentLeft=”true” android:layout_alignParentStart=”true”> </android.support.design.widget.CoordinatorLayout> Then, make sure you pass the CoordinatorLayout as the first … Read more

ConstraintLayout views in top left corner

As stated in Constraint Layout guides: If a view has no constraints when you run your layout on a device, it is drawn at position [0,0] (the top-left corner). You must add at least one horizontal and one vertical constraint for the view. I guess you haven’t applied any constraints. Either manually apply constraints to … Read more

Is there a way to get current activity’s layout and views via adb?

Use adb shell uiautomator dump command: Usage: uiautomator <subcommand> [options] Available subcommands: help: displays help message runtest: executes UI automation tests runtest <class spec> [options] <class spec>: <JARS> < -c <CLASSES> | -e class <CLASSES> > <JARS>: a list of jar files containing test classes and dependencies. If the path is relative, it’s assumed to … Read more

EditText not scrollable inside ScrollView [duplicate]

EditText EtOne = (EditText) findViewById(R.id.EditText01); EtOne.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (v.getId() == R.id.EditText01) { v.getParent().requestDisallowInterceptTouchEvent(true); switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_UP: v.getParent().requestDisallowInterceptTouchEvent(false); break; } } return false; } });

Shaped drawable with selectableItemBackground as background

Having round_corners.xml: <?xml version=”1.0″ encoding=”utf-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android” android:shape=”rectangle”> <solid android:color=”@android:color/transparent”/> <corners android:radius=”15dp” /> <stroke android:width=”1px” android:color=”#000000″ /> </shape> And my_ripple.xml: <?xml version=”1.0″ encoding=”utf-8″?> <ripple xmlns:android=”http://schemas.android.com/apk/res/android” android:color=”?android:attr/colorControlHighlight”> <item android:id=”@android:id/mask”> <shape android:shape=”rectangle”> <solid android:color=”#000000″ /> <corners android:radius=”15dp” /> </shape> </item> <item android:drawable=”@drawable/round_corners” /> </ripple> And button: <Button android:background=”@drawable/my_ripple” … /> Will result in this: See this article.

Changing CardView shadow color

Consider this thread in twitter, where Nick Butcher talks about how to implement the feature: See outlineAmbientShadowColor, outlineSpotShadowColor, spotShadowAlpha and ambientShadowAlpha attributes for details. Unfortunately, that’s possible from API 28 onwards. For lower APIs Nick has shared a gist. Here’s the result: Running on API 21 This technique isn’t directly connected to CardView, it can … Read more

Using clipRect – explanation

Canvas.clipRect(left, top, right, bottom) reduces the region of the screen that future draw operations can write to. It sets the clipBounds to be the spacial intersection of the current clipping rectangle and the rectangle specified. There are lot of variants of the clipRect method that accept different forms for regions and allow different operations on … Read more