I want to change the transparency of activity dynamically when I move the root element/view. How to do that?. I'm creating a module for which when user slide down the whole UI down to half of the screen vertically to finish the activity. But by default when the user slides down the layout default color white of activity is shown and when I set its theme to transparent previous activity is shown. I want to change the opacity of activity window dynamically when user slides down.
use this where you need:
Window window = this.getWindow();
window.setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
Related
I want to show tooltip window with two buttons skip and next on Appbar layout-tabs and BottomNavigation-menuitems. tooltip window should be displayed on semitransparent overlay. Background of the semitransparent overlay is Appbar layout-tabs and BottomNavigation-menuitems. If next is pressed the current tooltip should disappear and control moves to the next tabs and so on.How to achieve this
https://developer.android.com/reference/android/widget/PopupWindow
I am trying to keep my popupWindow when changing activities, and not recreating it each time I change activity.
Is this possible?
In the docs it says that -
This class represents a popup window that can be used to display an arbitrary view. The popup window is a floating container that appears on top of the current activity.
It states current activity, but is there a property I can set that will only change the activity behind the popup ?
Thank you !
I have requirement of creating two activities and their layout programmatically. And I want to create something like this,
Create a first activity and with a fixed background and second activity which will have a transparent area at all side so there the view of first activity will be shown.
Right now I am creating one activity and it shows OK.
and
setTheme( android.R.style.Theme_Translucent );
when i open second activity the view shows with margin but with the plain background and not the transparent view of first activity.
I have set the back ground of second activity like this, rLayout.setBackgroundColor(Color.parseColor("#80000000"));
It is showing the grey color at background.
I know a one work around by creating dialog, But it would be better to use activity as per our requirement.
You can create a transparent theme in styles and then use that style for your transparent Activity.
Refer to this answer:
How do I create a transparent Activity on Android?
I have Login Activity with a background image and a frame layout.
The framelayout will be replaced by a relative layout which contains three edit text boxes in the relative layout and a button at relative layout's bottom i.e., alignParentBottom = true.
When I focus on any of the edit text boxes the keypad raises ans I want all of them to move accordingly and the button at bottom should be immediately above the keypad so I am using adjustResize in my manifest, but this is making my background image to get resized i.e., compressed and displaying it within the visible space of the screen.
I need my background image not to move while all other components should be moving according to the screen.
If I use adjustPan the button which is aligned at parent bottom is not getting placed above the keypad and is invisible behind the softpad.
Please help me in this regard if anyone knows the way to resolve this requirement.
Thanks.
Try adding android:windowSoftInputMode="stateVisible|adjustPan" to your activity in the manifest file.
Explained here:
adjustPan
The activity's main window is not resized to make room for the soft
keyboard. Rather, the contents of the window are automatically panned
so that the current focus is never obscured by the keyboard and users
can always see what they are typing. This is generally less desirable
than resizing, because the user may need to close the soft keyboard to
get at and interact with obscured parts of the window.
If it's top layer just instead of setting that layer background you set that activity custom theme with that background. That way it does't resize. At least that worked for me.
I have one Activity which displayed some Dialog boxes and Progress bars.
This activity does not have call to setContentView as this Activity does not have Screen Layout. It has been just used for displaying Dialogs and progress bar dialogs.
Now what happens is that Activity Displays Dialog box along with the Blank Activity Window on back of the Dialog, So i want to hide make it transparent so it will look like we are just displaying Dialog.
Thank,
PP.
Use this attribute for your activity
<activity android:theme="#android:style/Theme.Translucent">
This will make activity background transparent.
In your activity tag(in manifest) which is displaying progressbar or dialog
put this above attribute android:theme="#android:style/Theme.Translucent
This will work...
Try applying the dialog theme to this activity:
In your manifest file add to the activity element this attribute: android:theme="#android:style/Theme.Dialog"
Copied from background - Android: make everything around dialog darker
All you need to do is play around with the dimAmount field in the
WindowManager.LayoutParams:
WindowManager.LayoutParams lp = myDialog.getWindow().getAttributes();
lp.dimAmount = 0.7f