0

AndroidとJavaではかなり新しい。

ここであなたに簡単な質問をします。

私のアプリケーションはとてもシンプルです。ユーザーに表示する画像のギャラリーがあります。彼が画像をクリックすると、新しい画像が読み込まれます。一番下にadmobがあります。

しかし、必要に応じてそれらを配置することはできません。現在、admob は表示されておらず、幅に十分なスペースがないというエラーを返しています。画面の端から端まで画像を合わせたい。現時点では、画像は四方から大きな黒い縁取りがあります。

これが私の活動です:

<RelativeLayout 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:background="#000000"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" xmlns:app="http://schemas.android.com/apk/lib/com.google.ads">

<com.loopj.android.image.SmartImageView
    android:id="@+id/image_switcher"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<com.google.ads.AdView
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:id="@+id/ad"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    app:adSize="SMART_BANNER"
    app:adUnitId="738a44d913034b9f" >

</com.google.ads.AdView>

4

3 に答える 3

0

ImageView が Ad で使用可能なすべてのスペースを使用するようにするには、次のコードを使用します。

<RelativeLayout 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:background="#000000"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" xmlns:app="http://schemas.android.com/apk/lib/com.google.ads">

    <com.loopj.android.image.SmartImageView
        android:id="@+id/image_switcher"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/ad" />

    <com.google.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
        android:id="@+id/ad"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        app:adSize="SMART_BANNER"
        app:adUnitId="738a44d913034b9f" >

    </com.google.ads.AdView>
</RelativeLayout

このようにして、ImageView は常に Ad の上に表示されます。

Stephane のソリューションを使用する場合は、RelativeLayout を LinearLayout に変更する必要があります。

于 2013-06-12T13:31:05.637 に答える
0

SmartImageViewセットの高さが になっているmatch_parentため、AdView

<com.loopj.android.image.SmartImageView
android:id="@+id/image_switcher"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
于 2013-06-12T13:18:39.657 に答える