在LinearLayout中,我的添加无法显示广告没有足够的空间,当我将其更改为RelativeLayout广告可以显示但是,我保留在顶部的按钮消失了。请帮我。而且,如果可能的话,我想把我的添加放在底部。感谢。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="25"
android:onClick="gotoPreviousImage"
android:padding="10dip"
android:text="<" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="50"
android:onClick="setAsWallpaper"
android:padding="10dip"
android:text="Set as Background" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="25"
android:onClick="gotoNextImage"
android:padding="10dip"
android:text=">" />
</LinearLayout>
<ImageView
android:id="@+id/backgroundPreview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:contentDescription="Preview of the wallpaper to choose"
android:scaleType="fitXY" />
<com.google.android.gms.ads.AdView
android:id="@+id/AdView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adUnitId="Unit_ID"
ads:adSize="SMART_BANNER"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="25"
android:onClick="gotoPreviousImage"
android:padding="10dip"
android:text="<" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="50"
android:onClick="setAsWallpaper"
android:padding="10dip"
android:text="Set as Background" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="25"
android:onClick="gotoNextImage"
android:padding="10dip"
android:text=">" />
</LinearLayout>
<ImageView
android:id="@+id/backgroundPreview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:contentDescription="Preview of the wallpaper to choose"
android:scaleType="fitXY" />
<com.google.android.gms.ads.AdView
android:id="@+id/AdView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adUnitId="Unit_ID"
ads:adSize="SMART_BANNER"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
/>
</LinearLayout>
答案 0 :(得分:0)
尝试以下方法:使用framelayout
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout android:layout_gravity="top"
android:gravity="top"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="25"
android:onClick="gotoPreviousImage"
android:padding="10dip"
android:text="<" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="50"
android:onClick="setAsWallpaper"
android:padding="10dip"
android:text="Set as Background" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="25"
android:onClick="gotoNextImage"
android:padding="10dip"
android:text=">" />
</LinearLayout>
<ImageView
android:id="@+id/backgroundPreview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:contentDescription="Preview of the wallpaper to choose"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher" />
<com.google.android.gms.ads.AdView
android:id="@+id/AdView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="bottom"
ads:adSize="SMART_BANNER"
ads:adUnitId="Unit_ID" />
</FrameLayout>
让我知道它是否有效
答案 1 :(得分:0)
//Replace this code with your xml code and replay me
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="25"
android:onClick="gotoPreviousImage"
android:padding="10dip"
android:text="<" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="50"
android:onClick="setAsWallpaper"
android:padding="10dip"
android:text="Set as Background" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="25"
android:onClick="gotoNextImage"
android:padding="10dip"
android:text=">" />
</LinearLayout>
<ImageView
android:id="@+id/backgroundPreview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:contentDescription="Preview of the wallpaper to choose"
android:scaleType="fitXY" />
</LinearLayout>
<com.google.android.gms.ads.AdView
android:id="@+id/AdView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adUnitId="Unit_ID"
ads:adSize="BANNER"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>