Android:我需要安排应用程序的布局 [英] Android : I need to arrange the layout of my application

查看:84
本文介绍了Android:我需要安排应用程序的布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用eclipse制作了第一个Android应用程序.现在,我需要安排版式,因为我的版式现在可以在WebView的主要内容上方显示Google AdMob广告.另外,当我旋转手机并进入横向模式时,AdMob广告仅位于屏幕的一半.如何解决此问题,如何使Google AdMob拥有自己的空间,就像进度条一样,不显示在WebView上.这是我的布局:

I made my first Android application using eclipse. Now I need to arrange the Layout because my layout now show the Google AdMob ads over the main content, over the WebView. Also, when I rotate the phone and it gets into Landscape mode, the AdMob ads are only on the half of the screen. How can I fix this and how can I make the Google AdMob to have its own space, just like the progressbar, not to be shown over the WebView. This is my layout:

<?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">

<ProgressBar
android:id="@+id/web_view_progress_bar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="15dip"
android:padding="2dip"
android:progressDrawable="@drawable/colorprogress" />

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<ImageView
android:id="@+id/splash_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/desc"
android:scaleType="fitXY"
android:src="@drawable/splash"
android:visibility="visible" />

<WebView android:id="@+id/web_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:visibility="gone" />

<com.google.ads.AdView android:id="@+id/adView"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   ads:adUnitId="a1500108406597c"
   ads:adSize="BANNER"
   ads:loadAdsOnCreate="true"
   android:layout_alignParentBottom="true"/>

</RelativeLayout>
</LinearLayout>

推荐答案

已将AdView放在RelativeLayout内,这会将它放在其中的项目顶部.

You've put the AdView within the RelativeLayout, which will put it on top of the items in there.

您只想将其放在LinearLayout内;我已经向您展示了您想要在ProgressBarRelativeLayout之间使用的方法:

You want to put it within the LinearLayout only; I've shown you what you have to do if you want it between the ProgressBar and RelativeLayout:

<?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">

    <ProgressBar
    android:id="@+id/web_view_progress_bar"
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="fill_parent"
    android:layout_height="15dip"
    android:padding="2dip"
    android:progressDrawable="@drawable/colorprogress" />

    <com.google.ads.AdView android:id="@+id/adView"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       ads:adUnitId="a1500108406597c"
       ads:adSize="BANNER"
       ads:loadAdsOnCreate="true"
       android:layout_alignParentBottom="true"/>

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

        <ImageView
        android:id="@+id/splash_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:contentDescription="@string/desc"
        android:scaleType="fitXY"
        android:src="@drawable/splash"
        android:visibility="visible" />

        <WebView android:id="@+id/web_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="none"
        android:visibility="gone" />

    </RelativeLayout>
</LinearLayout>

当然,如果要在底部显示,请将其放在</LinearLayout>标记上方.

Of course, if you want it at the bottom instead, put it above the </LinearLayout> tag.

这篇关于Android:我需要安排应用程序的布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆