320dp
のバナーがありますが、480x800
アンドロイドエミュレータの全幅を満たしています。ここで320dpの幅広い画像がAndroidエミュレータの画面全体を占めています
は、バナーのXMLです:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/add_banner"
android:layout_width="320dip"
android:layout_height="50dip"
>
<ImageView android:id="@+id/add_image"
android:layout_width="320dip"
android:layout_height="50dip"
android:src="@drawable/your_ad_here"
/>
<Button android:id="@+id/btn_addclose"
android:layout_width="25dip"
android:layout_height="25dip"
android:gravity="center"
android:layout_alignTop="@id/add_image"
android:layout_alignRight="@id/add_image"
android:text="x"
/>
</RelativeLayout>
私のように私のmain.xmlファイルに含まれている:私のエミュレータがあることを確認するために
<include android:id="@+id/add_banner"
layout="@layout/tlp_add_banner"
android:layout_width="320dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"/>
480x800
私は実行時にメトリックを記録しました。それは480x800
です。それでなぜバナーが幅全体を占めるのですか?
私は代替リソースを提供しようとしましたが、240dpi(高密度)の320x50イメージを 'drawable-hdpi'フォルダに入れました。それでも助けてくれなかった。 –
Androidは実際の画像に設定されているDPIを気にしません(メタデータだけであり、多くの場合間違っている可能性があります)。 480x75の画像を 'drawable-hdpi'に入れてください(幅と高さを1.5倍しただけです)。 – Felix