0

Eclipseを使用して最初のAndroidアプリケーションを作成しました。次に、レイアウトを配置する必要があります。これは、レイアウトでメインコンテンツ上、WebView上にGoogleAdMob広告が表示されるようになったためです。また、携帯電話を回転させて横向きモードにすると、AdMob広告は画面の半分にしか表示されません。これを修正するにはどうすればよいですか。また、プログレスバーのように、WebViewに表示されないようにGoogleAdMobに独自のスペースを持たせるにはどうすればよいですか。これは私のレイアウトです:

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

1 に答える 1

0

AdView内にを配置RelativeLayoutしました。これにより、そこにあるアイテムの上に配置されます。

LinearLayoutあなたはそれを唯一の中に入れたいです。ProgressBarとの間に必要な場合は、何をしなければならないかを示しました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>タグの上に置きます。

于 2012-08-22T17:04:37.523 に答える