Transparency in Background Picture - java

I want to achive that I have a transparent background BUT with a picture !
So if got this in the XML file of my layout :
android:background="#drawable/wallpaperpic"
Now I want to transparent it so the background menu (f.ex. widgets or app menu) is seeable but also my drawable/wallpaperpic and the rest of my buttons etc are normal (100%).Hopefully I was able to express my self !
My Background : https://amazingpict.com/wp-content/uploads/2015/04/polygon-texture.jpg
I want to have this
WHERE you also can see my background picture a bit

Try to set the alpha property of the view, like:
yourView.serAlpha(10);

If, as I'm guessing now, you have two layouts, one within the other, where the parent layout has the background, you can do this in the child layout:
android:background="#null"
This way, you can see the background, and your elements are intact.

Option 1 is to convert your image to a PNG and add an alpha channel.
Option 2 (which I would recommend) is to have a separate view that acts as your background, and set the alpha property for this view only. You can use a FrameLayout to put this background view underneath your other controls.

In my opinion use TintableBackgroundView.
TintableBackgroundView.

If you launch your activity the normal way, the system will not render anything behind it (i.e. the launcher will be completely gone - it could even remove it from memory).
You'll need to implement your activity as an alert window. This answer has details on how to implement it.

Related

Why my emulator/device and design screen in AS show different layout ? I am concerned about the thing below 'BILL TOTAL'

Please click here to view the screenshot.Please tell me the reason. I can send you the codes if u require.
enter image description here
The design preview will not show any live running code or logic that the device or emulator will. You can override this by adding one of the tools references to the layout, but otherwise it will just use the default data set inside the XML layout attributes.

How to develop a walk through dialog that appears on the first launch?

I would like to develop a Dialog which is composed of 3 steps to guide the user when he launches the app for the first time.
The following image is an example of what I would like to achieve:
1- I would like to know how to add a mark to close the dialog at the top-right corner?
2- How can I implement the small circles at the bottom of the screen that indicates the current step? Can they be created programmatically?
3-Only to be sure, I decided to navigate between the Dialog steps using a ViewFlipper. Is this the right approach?
Thanks in advance.
I would like to know how to add a mark to close the dialog at the
upper right corner?
Don't do that. That looks like it was a straight port from an iphone app. Use the native android dialog containers/buttons.
How can I implement the small dots at the bottom of the screen that
indicates the current step?
What have you tried? There's a million ways of doing this depending on the rest of the workflow.
Only to be sure, I decided to navigate between the dialog steps using
a ViewFlipper. Is this the right approach?
Maybe. It depends what you're displaying. If you're only displaying a single image or something simple, then that might be the best approach. I would create different dialog fragments ( you are using fragments, right?) for the different steps. That way you can automatically push them to the back stack as you move through the workflow.
one of the ways to implement the "little dots on the bottom" is :
include the dots in every image you are creating.
draw one of the dots highlighted in every image
flip through the images in order of the highlighted dots. (or highlight the dots in the order you want to show your images)
but this would make your dots disappear during the images are flipped.
if you want to avoid that :
create two different image views , one acts as a container for the main image, the other as a container for the dots, place the 1st image view above the other.
create a no of images containing just a no of dots, each with one of the dots highlighted
flip through both the imageViews in synchronization
use a "flip animation" in the upper image view
use no animation, or a minimal animation for the dots.
This will produce the desired effect. Hope this helps :-)

Android - How to display another overlay in onTap action of another overlay

I am using MapView to display some polygons (zones) as Overlays on the canvas. I extended the class Overlay and now would like to implement the onTap method. After user taps on one of these zones another overlay should be displayed. I would like to define the layout of this overlay as a normal XML layout and than just inflate it and display.
I have already looked on one example called android-mapviewballoons, but it uses itemized overlays which take an Drawable resource and display it on the mapview. This drawable can than be taped. In my case I want my zone (polygon) to be the clickable resource. Can anyone help me please?
Step #1: Implement onTap() in your Overlay and confirm you are getting control when you want to.
Step #2: Adjust your existing layout such that the MapView is in a container that supports Z-axis ordering, like a RelativeLayout
Step #3: In onTap(), add another child to the container (and, eventually, get rid of that child, when appropriate)
Here is a sample app from one of my books demonstrating this with an ItemizedOverlay, but there should be no significant difference for using the technique with a regular Overlay.

Change app background

I'm currently making an android app in which I'd like the user to be able to change the background image.
I've got 3 images and a screen where I can choose a picture and a button for applying.
The issue:
I can allow the user to see all images in the way I want, but I don't know how to set the selected image as app background.
What I want to do:
I want the user to click a button, which exports the selected image to "bakgrund.png" in "/res/drawable-mdpi" and replaces the current one. This would allow me to easily integrate the background switcher. Renaming of current files also works.
PS: My current background images are located in /res/drawable-mdpi named 1.png 2.png and 3.png.
Easiest way would be to call the setBackgroundResource(image_id) method on the root layout. Like if you have a LinearLayout which has android:id="#+linear" as the root layout in the layout xml, then this code will help:-
LinearLayout linearLayout=(LinearLayout) findViewById(R.id.linear);
linear.setBackgroundResource(R.drawable.1);//call this in the OnClickListener's OnClick Method
Firstly, you need different themes which has different backgrounds. So you may use this.setTheme method in your Activity.
Indeed I suggest you, two different layout (with different backgrounds but have same components) and using setContentView during onClick.
I hope it solves your issue.

how to switch between layout at runtime in android?

i have four images in a row at the top , on click of each icon i want to change the underlaying background (image) and the controls on the layout , this way it achieves tab like structure and behavior , i want to know whats the best way to achieve this ? I think i will have four layouts each layout having one image highlighted showing that tab selected and corresponding components on layout, and will change this layout when user clicks on image.
Is this a good idea to achieve this ? or i have different solution available ?
its nice if u give me some idea about necessary features or API or layout component related code
Suggestions are welcome thanks!
That is not a good idea. You should use android's tab architecture. Here is a example at developer.android
you can change layouts by switching views to invisible and visible. but it's not a good idea when you want to change 4 layouts.
It becomes hard to maintain the code if you have 4 layouts switching.
It's better to use Tabs which will help you in preserving the state of the each layout.
Customize the tabWidget to make it look like you have 4 buttons on the top, not the tabs.
HTH.

Categories

Resources