How to put button on webview - android

I want in background I will show an webview. and on that webview on foreground i want to place another button. How to achieve the same. I can load the googlemap using map view. but unable to place a button on it. I am showing google map in an mapview.
Thanks

Thank you all. I got the solution by using Framelayout.
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/header"
android:layout_above="#+id/footer">
<WebView
android:id="#+id/GD_webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#+id/footer" />
<Button
android:layout_centerVertical="true"
android:id="#+id/setTimeBtn"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:background="#drawable/settime"
android:layout_gravity="bottom"
android:layout_marginBottom="15dip"></Button>
</FrameLayout
>

Related

Android Horizontal Scroll VIew like gallery

I want to make horizontal scroll view in android like gallery view, in which centered image zooms in while scroll. Often seen in web but I haven't found one in andriod. Here is an example from one iOS app.
I have tried with HorizontalScrollView, ListView, ViewPager but not able to reproduce zoomed Effect in center while scroll, and next images comes from behind.
You can use CoverFlow .Its a view for Android with several fancy effects.
https://github.com/davidschreiber/FancyCoverFlow
https://github.com/moondroid/CoverFlow
May be you can use a ViewPager inside a TabHost to get something close to what you are looking for.
<TabHost
android:id="#+id/calendar_add_edit_th"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/ll_tabs_com"
android:layout_width="match_parent"
android:layout_height="40dp"
android:baselineAligned="false"
android:orientation="horizontal"
android:weightSum="1">
<TabWidget
android:id="#android:id/tabs"
android:layout_width="match_parent"
android:layout_height="37dp"
android:layout_gravity="bottom"
android:orientation="horizontal" />
</LinearLayout>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="#+id/ll_tabs_com"
android:background="#fff" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ll_tabs_com">
<android.support.v4.view.ViewPager
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#fff" />
</RelativeLayout>
</RelativeLayout>
</TabHost>
You can Directly Use View Pager with DepthPage Transformation to Acheive as you like according to Android Documentation.
You can Acheive like :Demo of ViewPager
To achieve this kind of View
View Pager with Transformation Speed in Android

put a button in frameLayaout

I have a small application with the camera and I have a device which is not a problem but if I can change the app will improve much aesthetically.
I put the xml code of the activity:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/layout">
<FrameLayout
android:id="#+id/preview"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="0dip">
</FrameLayout>
<Button
android:id="#+id/buttonClick"
android:layout_width="109dp"
android:layout_height="105dp"
android:layout_gravity="center"
android:background="#drawable/obutrador2" >
</Button>
</LinearLayout>
When I run the application, there is a white stripe along the entire height of the screen occupied by the button. How I can fix this? It would make the button appear above the image that the camera is capturing, as the app that has the default phone.
The problem is how to position the frame layout so that it fills the screen and center the button at the bottom. If I make the FrameLayout full-screen, the button disappears.
I leave a link to a photo of what happens:
https://www.dropbox.com/s/jbns8jddtwxjhdp/IMAG0348.jpg
I think you should define Button inside the FrameLayout like this.
You can make FrameLayout as parent layout and you can place button where ever you want
<FrameLayout
android:id="#+id/preview"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="#+id/buttonClick"
android:layout_width="109dp"
android:layout_height="105dp"
android:layout_gravity="center"
android:background="#drawable/obutrador2" >
</Button>
</FrameLayout>
Hope This should be work for you...Thanks

How do I add a button to a Webview on Android?

I am generating a webview programmatically I would like to add a button over the webview. I am able to add a normal button, but that comes before the webview, not over it.
Is there a way that I can add the button over the webview?
Use like this ...
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="500dp"
android:layout_weight="1"
>
<WebView
android:id="#+id/main_web "
android:layout_width="fill_parent"
android:layout_height="500dp"
android:layout_weight="1" />
<ImageButton
android:id="#+id/refresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
></ImageButton>
</FrameLayout>
You can add the button on top of a WebView by using a FrameLayout.
First add the WebView to the Layout, then the Button and adjust the gravity of the Button so that it sits where you want it to.

how to show TextView,Buttons On MapView (To Overlap On It)..?

In my application i have mapview and I want to show distance in a textview and also a Button ,
I have done this.and tried this..
http://www.anddev.org/post3452.html#p3452
PROBLEM IS>>>>
I WANT TO SHOW TEXTVIEW AND BUTTON OVER THE MAP VIEW..
so I can See MAPVIEW in Full Screen..with other items over it(as we can see map through textview)..
Any SPECIFICATION NEEDED TO BE DONE IN xml FILE..??
Please..Reply me..
Thank You..in advance
Yes you can do that.
For eg:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<com.google.android.maps.MapView
android:id="#+id/mapView" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:enabled="true"
android:layout_centerInParent="true" android:clickable="true"
android:apiKey="your api key" />
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Click"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true" android:id="#+id/clickBtn" />
</RelativeLayout>
create a layout with the RelativeLayout and embed the map view in it. Once set, set the relative position of your components as per your need.

Android layout issue with buttons below WebView

So I have a webview I'd like to display as a dialog. I'd like the webview to fill the entire screen, except for a button below it that I'd like to stay at the bottom of the dialog regardless of how much content is in the webview. Currently my webview fills up the dialog just enough to push the button off the screen. I'm sure this is something pretty easy but for the life of me, I haven't been able to find the magical combination of layouts, views and attribute values to get it to play nice. Just to be clear, I've gotten it so the button floats over the webview but I'd like the webview to stop just above the button and scroll, if that makes sense.
<RelativeLayout android:id="#+id/RelativeLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<WebView android:id="#+id/webview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<Button android:text="Ok"
android:id="#+id/btnOk"
android:layout_width="120px"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
You will want to use android:layout_above="#+id/btnOk" for your webview, and do fill_parent for width and height of the webview.
However, it is important to note, that in 1.5 and below, RelativeLayout views need to be specified in order in your xml to be recognized correctly.. in other words, you have to have your Button first, then the WebView, since the WebView will reference the button. I think this has been changed in 1.6 or 2.0, but I am not positive which.
<RelativeLayout android:id="#+id/RelativeLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<Button android:text="Ok"
android:id="#+id/btnOk"
android:layout_width="120px"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"/>
<WebView android:id="#+id/webview"
android:layout_above="#+id/btnOk"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</RelativeLayout>

Categories

Resources