create webview on top of the other layouts which fits to screen - android

Can I create a WebView on top of all the other layouts dynamically?
Actually I want to have WebView on the top of all the layout and which fits to the screen?
I am using LinearLayout. Can I do this using code ?

Create a FrameLayout and place your LinearLayout and WebView in it.
Since in FrameLayout Child views are drawn in a stack. you will have both the views overlapping on each other. control their visibility to switch between your views.

Related

Purpose of FrameLayout?

All examples I find for FrameLayout use the FrameLayout to stack multiple children on top of each other. Even e.g. Stackoverflow answer here says
You use a FrameLayout to stack child views on top of each other,
The official documentation however states
FrameLayout is designed to block out an area on the screen to display a single item. Generally, FrameLayout should be used to hold a single child view,
While adding multiple children to it is possible, it sounds like it's just a side effect.
So, what's the originally intended use case for a FrameLayout with a single item? Anyone has an example for that?
There are different purposes why FrameLayout with only one child can be useful. Imagine having a loading spinner that should be centered but not fill the whole page but also you want the content to be hidden when the loading spinner is shown. Possible solution: FrameLayout with match_parent for width and height and a background color and the ProgressBar (Loading spinner) with android:layout_gravity=center as only child of the FrameLayout. So now you can set the android:visibility of the FrameLayout to show or hide the whole thing.

How to make a layout like S Health for android?

I want to make a layout like S Health (Right side of picture)
To me it seems like the layout is an ActionBar with a TabHost and a ScrollView.
The ScrollView then seems to be a vertical linear layout with a SurfaceView at the top.
My question is, am I right in thinking that I can use a SurfaceView to create a chart similar to the one pictured and then place other views under for the text and graphs?
How can a lock the ScrollView from moving up and down if the user starts by moving the chart horizontally?

Showing a scrollbar with a ViewAnimator

I have a view animator that I am adding images to dynamically via a web service call. However, the scroll bar refuses to show up no matter how many pics I add to the ViewAnimator. Thoughts?
The ViewAnimator is not a scrollable layout. Adding a childview to view animator will not show the added view if you don't have a mechanism to call showNext or showPrevious.
Maybe you want to use a ScrollView instead? You nee to create a ScrollView that contains a LinearLayout with a vertical orientation. You can now add images dynamically to the LinearLayout and the ScrollView will increase in size.

How to display a custom view in Android?

I am generating a custom View that contains a number of drawables that are added to the View dynamically. This means the View's size could be anything, and is likely to stretch off the screen. Where it does stretch off the screen I want scrolling to be enabled.
So far I have tried:
adding the custom view directly to my Activity - this displays the drawables ok, but with no scrolling
adding the custom view as a child to a ScrollView and setting the ScrollView as the content in the Activity - this doesn't display anything.
How do I generate a custom view of arbitrary size, display it and have scrolling where it is too big for the screen?
Adding it to a ScrollView should be fine. Remember:
A ScrollView is a FrameLayout, meaning
you should place one child in it
containing the entire contents to
scroll; this child may itself be a
layout manager with a complex
hierarchy of objects. A child that is
often used is a LinearLayout in a
vertical orientation, presenting a
vertical array of top-level items that
the user can scroll through.
To make sure your "custom view" is working fine, first try to add a LinearLayout to the ScrollView and then add drawables to the LinearLayout.

How to Reload the Same layout on View Flipper in Android?

I have an Linear Layout inside the View Flipper. When i fling/swipe the layout the same layout reloads the same layout with the animations slide_left_out and slide_right_in. I just have only one layout view. it has the values the image view and text view. When i swipe the view it just change the next value to that views. Any Idea?
How did you add the swipe/fling functionality? In other words, when the screen is "flung", that's where your code has to come in and "flip" the viewflipper to a different layout.
AFAIK There isn't a built-in way to fling the viewflipper without having to write some code to handle the fling and manually change the viewflipper layout (index).
EDIT:
Basic Gesture Detection
Flipping Views using ViewVlipper.setDisplayedChild()

Categories

Resources