How to add a semi transparent overlay to the view in Android? - android

As shown in the picture, I need similar functionality when the user touches/clicks on the EditText. When the keyboard is open , the view should be covered by a semi-transparent overlay. What is the best way to implement this?
I have my view inside a FrameLayout.

You could add a simple View as the last child in your FrameLayout and set its background to a semi-transparent color. Whenever the EditText changes focus, set the visibility of the overlay View appropriately (View.VISIBLE or View.GONE).

Starting from JellyBean 4.3 (API 18) you probably may do this using new ViewOverlay and ViewGroupOverlay - just add semi-transparent overlay above any parent View or ViewGroup. Here is good introduction into this system.

Related

How to use Bottom Nav View and AppBarLayout as an overlay and animate them in Android

I wanted to know how to use Bottom Nav View and AppBarLayout as an overlay and animate them (hide/show together on touch) just like apps like Camscanner do when viewing image? I want this behavior so that the canvas beneath it can use fullscreen.
Update
Note: This screenshot is from Gallery Go app by Google, it also hides the ActionBar and BottomNavBar.
Update 2
I used the UiAutomatorViewer to check the app's UI and found that it actually uses a LinearLayout with ImageViews for the AppBar and TextViews for the Bottom Nav View.

How to cover a view's foreground programmatically with a transculent color

I want to cover views foregrounds with a translucent CustomSeekBar programmatically while it has this foreground:
android:foreground="?attr/selectableItemBackground"
Because of my layouts are very complicated and there are lots of views to cover with a transculent color, I dont want to put my CustomSeekBar to each layout so many times and make them visible.
I want to have the ripple effect still after covering foreground.
It will raise from below of view like that:
Note :
I have my CustomSeekBar.
The covering with translucent color means solution can be
1. setting a translucent color as foreground (but probably I will lose ripple effect)
2. inflating and putting a prepared view (CustomSeekBar) to each view I want. (I dont know how to do it)
I dont know how to do that.
Thanks in advance..

Material Color Reveal via Radial Reaction

In Android, a feature called radial reaction exists (find it at https://material.google.com/motion/choreography.html#choreography-radial-reaction).
After a bit of research, I discovered that we can use this to reveal views (see http://android-developers.blogspot.com/2014/10/implementing-material-design-in-your.html and http://pulse7.net/android/android-create-circular-reveal-animation-and-ripple-effect-like-whatsapp/).
Is it possible to reveal a certain color, instead of a view? (For example, change the background color to red when the user clicks the layout)
For now, only revealing a view is supported out-of-the box in ViewAnimationUtils https://developer.android.com/reference/android/view/ViewAnimationUtils.html
You could have your layout file define two different background layouts (LinearLayouts for example). The circular reveal would reveal whichever view you need.

Implementing a floating dropdown panel for android toolbar

Iam working on an tablet app that needs a dropdown panel that flots on top of everything inclunding my toolbar. And should look something like
Can you please suggest the best UI widget that best suits this purpose, putting into consideration elevation and alignment inside the toolbar
For me it's a PopupWindow shown with showAsDropDown. You would have to prepare a layout with highlit back button and the product list. Then create a PopupWindow with that layout set as a content.
The other option is to prepare the popup as a custom, hidden layout lying on your main screen (use FrameLayout) and change its visibility when needed.
I'm not sure, but you may need a custom ViewOutlineProvider with convex path outline. PopupWindow may be unable to drop a non-rectangular shadow like on your screenshot. In such case you would have to set its background to transparent (or maybe null?), disable window's shadow and cast shadow with custom ViewOutlineProvider.

Navigation Drawer clickable area

I have found a strange behavior on the clickable area for opening the Navigation Drawer:
Android 4.2.2+
The application icon and the action bar title are clickable (see red box on the image)
Android 4.2.2-
Only the application icon is clickable (see yellow box on the image)
Any workaround for this? I would like the Android 4.2.2- would have a bigger clickable area.
So, the reason this occurs is due to the way the ActionBarView inflates the home layout. Starting in Jelly Bean mr2, they added a layout called action_bar_up_container, which is added as a parent to the ActionBar home layout when it's first inflated. Before this; however, the action_bar_title_item wasn't added to the action_bar_up_container because it didn't exist and although contains a background, is only enabled and clickable when ActionBar.setDisplayShowHomeEnabled is set to false.
So, you could enable the title container and make it clickable like this:
final int abUp = getResources().getIdentifier("up", "id", "android");
final View titleContainer = (View) findViewById(abUp).getParent();
titleContainer.setEnabled(true);
titleContainer.setClickable(true);
But because of the way each View is inflated before Jelly Bean mr2, the up container and title container wouldn't be linked, so to speak.
So, it seems like the only workaround would be to attach a View.OnTouchLIstener to the titleContainer and implement some sort of pseudo-selection on MotionEvent.ACTION_DOWN and MotionEvent.ACTION_UP, which seems like more trouble than its worth to me, but if there's a better solution I welcome it.
Although, I suppose you could also call ActionBar.setCustomView and inflate a layout that mimics the home and title containers. This would probably be the easiest workaround.

Categories

Resources