Android Development: XML layout place ontop like watermark - android

Lets say i got an webview with my website for example. can i add like a watermark(textView this case) on top of the webview?
Is this possible to add a component on top of another without having that black space if you try to offset the text.
Need an transparent background and place the object on top of the other one
thank you!

There are two options for this. Using a FrameLayout you can have two separate layers that overlay one another.
Using a RelativeLayout you can position things such that they overlap.
In both cases, the ordering of elements in the xml file determines the Z ordering.

Yes just nest the WebView and TextView within a RelativeLayout and set the background of the TextView to be transparent as you said.

Related

Android Horizontal oriented LinearLayout - how to know how many TextViews will fit?

My Idea is adding TextViews with rounded corners background to a horizontal LinearLayout, so if next one wouldn't fit - I will add TextView to another LinearLayout below.
Is there a way to do so? I know it sound like a custom view, but I would like not to bother as much - to adjust height, make click area calculations istead of simple clickListeners
Sounds like a recyclerview using a flexbox layout https://github.com/google/flexbox-layout with flexWrap turned on.
You could also use is in a static layout as well.
With flexWrap it does all the calculations to see if the "item" can fit on a line and if not starts a new line.
Many examples on the github page.
You could keep adding text views in linear layout while checking if newly added text view is outside of linear layout horizontal boundaries, if it is you could remove it from linear layout and add it in new one but I see no reason why you would want to do that.

Need recommendations for overlay views or layouts in Android

In an Android app I have a background image and two buttons on it.
This is a partial screenshot:
I ask you for the best approach to click on the sinopsis button to show an overlay text, like this:
and also to click the fotos button to show an image slider, like this:
I don't want you to show me any code. I only need recommendations to know what kind of layouts or overlay views I should use to obtain the shown behaviours.
Thank you.
A simple TextView is enough. A TextView can have a background, translucent as in your case, or gradients, etc., and padding. You can fill it with Spanned Text so you could use hyperlinks, bold, colors, etc.. If you need scrolling, TextView also supports scrolling out of the box, but it'd be better to put it inside a ScrollView because the scroll will be smoother. In any case you don't need additional layouts.
You can just use a container layout (like LinearLayout. RelativeLayout, ScrollView, etc.. depending on what you want) and specify that to have a background image and then specify your drawable. You can then use TextView to display text. Don't forget though that you will have to create custom TextViews to achieve your design.
TextView can have transparent background and so, you can get the overlay effect.

Want to place multiple hidden buttons over a background image?

Not able to set hidden buttons over the background image, want to place hidden buttons exactly over the words (i.e total 5 hidden buttons over background image). Help!.
Try to use AbsoluteLayout or RelativeLayout with button alpha 0%.
Also consider doing it in another way. It may go wrong on different screen sizes and orienantions.
You should try to use RelativeLayout to do this (if you want to create a custom view, eg in corners). RelativeLayout is a Layout where the positions of the children can be described in relation to each other or to the parent.
See this link: RelativeLayout
See the example here and information from here

Custom buttons arangement in Android

I'm trying to build an Android app where I would like to display some Buttons in various places, as in the demo image attached.
The challenge here is creating the custom buttons and arranging them.
As for the custom Buttons, I guess I could achieve that using CustomViews or a simple button with a Custom Drawable as Background.
Are these the right points to start, any other ideas?
On arranging them, I have no clue how to achieve that.
As Android_Crazy and Closeratio have already said, a RelativeLayout is the most suitable option for custom placement of buttons in general. However, for the exact placement of buttons pictured in your example, a LinearLayout would work just fine.
In a LinearLayout you may place views under or above eachother (with android:orientation = "vertical", relevant for your example) or next to each other (android:orientation = "horizontal"). You can also add margin to your views to alter the horizontal position (layout_marginLeft or layout_marginRight) or the vertical position (layout_marginTop or layout_marginBottom).
As for the buttons' appearance, I always use custom background drawables, usually with a custom xml to add a different drawable for when the button is being pressed or selected.

Instructions layout for Android

I was looking into laying out some instructions on top of one of my applications like SoundHound does in one of their latest updates: http://i.imgur.com/D36nL.png
How is something like this achieved? Is this some sort of layout over another layout? Or a "dialog box" in a way?
You can create a frame layout with two children. The first would be the standard layout for the activity. The second would contain image views that display the help bubbles in the appropriate locations.
For more information see this: http://developer.android.com/guide/topics/ui/layout-objects.html#framelayout
Here is nice simple example: http://www.learn-android.com/2010/01/05/android-layout-tutorial/3/
You could just use a RelativeLayout with some elements having negative margins. They will overlap over other elements.

Categories

Resources