Android xml layout blank space - android

Iam developing a HTML5 Android app, and Iam stucked at basic xml layout of Android app. When I run my app in emulator and on my Android smartphone I have unexpected blank space on the right side.
http://i.stack.imgur.com/c3emH.png
Here is code form activity_main.xml file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<WebView android:id="#+id/web_engine"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>

Related

Video background on entire screen

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>

Xamarin Main.xml is missing from assets then Layout contains malformed xml - Root element is missing

I am starting out with Xamarin studio, I have build most basic forms project. In tutorials it shows how to edit layout in Main.xml, that is supposed to be in Resources/layout that is missing in my solution. So when I add it manually it then fails with error message The layout contains malformed XML and another one Root element is missing. When I opened the Main.xml in notepad I can see contents to be <?xml version="1.0" encoding="UTF-8" ?>.
How do contents of proper blank Main.xml supposed to be like?
Review that the markups are start and close correctly; for example,
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:background="#drawable/fondomizzou" **/>**
NOT
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:background="#drawable/fondomizzou"
**</RelativeLayout> />**
Figured it out myself
Click on source, then add
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
and that should do it.

Moving android adView code from Library layout file to the advert based app layout

I have an android app which is marked as library and two more apps (trial version and full) which are essentially using the library and only have a package name and little bit of code in there like one has to have adverts and others don't etc.
So all (99.9%) of the code lives in library whichever app is used.
The following is the main Layout xml file of the LIBRARY APPLICATION. The adView element is also present in this file and I would like only the adview Element to be somehow in the trial app's layout without duplicating the entire layout of the library.Trial app has no layout right now it just has the libray as dependency.
How can I achieve moving the adView element code from the layout below to the relevant app who right now has no layout.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.google.android.gms.ads.AdView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="#string/banner_ad_unit_id"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="4"
android:orientation="vertical" >
.... more code here
</LinearLayout>
<LinearLayout
android:id="#+id/info_window"
android:layout_width="fill_parent"
android:layout_height="100dip"
android:orientation="horizontal">
...more code here
</LinearLayout>
</LinearLayout>
Edit: Just to add little bit more detail the app has minApi 9 and does not use support library etc
I wouldn't remove the AdView from your library XML. I would instead use code in your apps to only load and show the banner ads in the relevant app.

Xamarin - error with layout file

I am trying to create a cross platform native app using Xamarin studio installed on windows.It currently targets Android.I am getting the following error.
Projects\sample\Android\Resources\layout\Main.axml(1,1): Error CS0116:
A namespace cannot directly contain members such as fields or methods
(CS0116) (sample.Android)
This is the generated layout file,I have not made any changes to it.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="#+id/myButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/hello" />
</LinearLayout>

webview is not taking full screen

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);

Categories

Resources