i have simple layout with two buttons as you can see in the image , when i click on google button it opens google website in the webview as you see it is not opening google website on full screen it is showing those buttons two ,but when i remove scrollbar from my main layout, then webview shows google website on the full screen, how can i fix this problem because i want to user scrollview in my main layout.. here is my main.xml
xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:id="#+id/btn_click_login"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_weight="2"
android:text="Google"/>
<Button
android:id="#+id/btn_gmail"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_weight="2"
android:text="Gmail"/>
<WebView
android:id="#+id/webview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
</WebView>
</LinearLayout>
</ScrollView>
when i click on google button it opens google website in the webview
as you see it is not opening google website on full screen
This is because probably you are using same Activity with same XML layout, where are another widgets. But solution is not difficult.
1. First create something like web.xml with one widget WebView.
2. Then create another class extending from Activity called for example WebBrowser.java
3. Add it to your Manifest.xml as <activity android:name=".WebBrowser"></activity>
4. In your WebBrowser class will set your layout with setContentView(R.layout.web) and initialize your WebView.
5. After clicking on Google Button create new Intent and start new Activity.
Intent i = new Intent(this, WebBrowser.class);
startActivity(i);
your web.xml can looks like
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<WebView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
Note: For support of full screen you can use
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
Related
I want to have a video background on my entire screen. Everything works correctly in java: it loops etc. The problem might be in xml.
Currently I have video on a top of the screen, it looks like this: (Video is perfeclty fitted in edges)
While my purpose is to have it entirely in my screen:
Please what should i make my xml look like to achieve my goal. Thanks.
XML:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/home_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<VideoView
android:id="#+id/surface"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</FrameLayout>
First you need to set the orientation to landscape since you said you purpose is in landscape mode
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); // add it below super.oncreate
If this code not working check out this link
or your could set the orientation in manifest just google it
And change this in your xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/home_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<VideoView
android:id="#+id/surface"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
/>
</FrameLayout>
In my android app i want to put a common footer for all the activities. I created a custom view which extends Relative Layout, which contains a ImageView. It'll change the source for every 10 sec depends upon the data from server. I had put my custom view class in every activity's XML file also.
Now my problem is, i'm unable to find the way how it will instantiated in every activity means how the result view will added to every activity.
Simply, i want Admob Advertisement like feature in my application.
This is One of my Activities XML layout:
Activity.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="0dp"
>
<RelativeLayout
android:id="____"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
----
----
</RelativeLayout>
<com.ninepstudio.movieme.activities.Banner
android:id="#+id/banner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#id/activity_movies_layout" />
</RelativeLayout>
I want to make a activity like a "Dialog", and I know two ways so far:
Way 1) In Android ApiDemos, it is implemented by adding the attribute to the activity like
android:theme="#android:style/Theme.Dialog">
The result is: the new Activity appears on top of the existing activity, that is what I want.
Way 2) I try to invoke setTheme(android.R.style.Theme_Dialog) in the Activity.onCreate(Bundle) method, and the new activity also appears, but the background is all black. This is not what I want. Code is as below:
super.onCreate(savedInstanceState);
setTheme(android.R.style.Theme_Dialog);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.selecte_date);
Can anybody tell me how to implement the effect by writing Java code?
The easiest way is to add a second layout in you xml which is a overlay of existing one.
then you can set the overlay to visible in your activity. So then you got multiple views in 1 activity.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#android:color/transparent" >
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:background="#android:color/transparent">
<ImageView
android:id="#+id/icon"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="#+id/title"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
<LinearLayout
android:layout_alignParentTop="true"
android:id="#+id/overlay"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/translucent_black"
android:visibility="false" >
</LinearLayout>
</RelativeLayout>
I'm a noob to android development and my webview resizes itself whenever i try to play video. In order to make the webview play video i had to add the line of code:
youtube.getSettings().setPluginState(PluginState.ON);
In my layout, I have my webview above a listview. However, now when the webview plays video it becomes fullscreen and covers listview. this was not happening before i added the line above. How do I stop my webview from resizing itself? Any help is greatly appreciated?
Here is my layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="#+id/LLvideos" >
<WebView
android:id="#+id/webViewyoutube"
android:layout_width="match_parent"
android:layout_height="350dp" >
</WebView>
<!-- List view -->
<ListView
android:id="#+id/videolist"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:divider="#00000000"
android:dividerHeight="0dp" >
</ListView>
Here is my video link
youtube.loadUrl("http://link.brightcove.com/services/player/bcpid1683318714001?bckey=AQ~~,AAAAC59qSJk~,vyxcsD3OtBPHZ2UIrFX2-wdCLTYNyMNn&bclid=1644543007001&bctid=1858951133001");
Sounds like you are have a scaling issue. Try youtube.setInitialScale(50). This should work.
Try setting the webview layout like this:
webview.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
I'm currently trying to create an application according the customer's specs, and these include a double tab set.
Meaning that the user needs to click in a tab at the bottom, and for example in the first tab, he will also see a set of tabs at the top where he can click (but when clicking in these, only the ones at the top will change, while the tabs at the bottom will remain the same).
How could I perform this with Android?
So far I could only implement the normal tabs creating a root item 'TabHost' just like this:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true" >
</FrameLayout>
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
</RelativeLayout>
</TabHost>
Thanks a lot in advance!
I found this, thanks to the ActionBar (and SherlockActionBar for pre-Honeycomb devices):
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/ActionBarTabs.html
and also this:
http://www.youtube.com/watch?v=gMu8XhxUBl8