2014-11-12 9 views
1

В LinearLayout мои добавления не могут показать, что места для рекламы недостаточно, когда я изменил их на объявления RelativeLayout, но кнопки, которые я держу вверху, исчезли. Пожалуйста, помогите мне. Кроме того, я хотел бы поместить мое добавление внизу, если это возможно. Благодарю.Объявления не могут отображаться должным образом, activity_main.xml

<?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="&lt;" /> 

    <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

попытку дать веса, как layout_weight для отдельного компонента ребенка – virendrao

+0

как вы показываете этот ImageView? Я думаю, у этого есть fill_parent для высоты и ширины. Поэтому попробуйте удалить его для momemnt и посмотреть, все ли работает отлично. – Darpan

+0

@ vo12 Не работает :(По-прежнему такая же ошибка «Недостаточно места для показа рекламы. Требуется 360x50 дп, но имеет только 360x0 дп». –

ответ

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="&lt;" /> 

      <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> 
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="&lt;" /> 

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

Позвольте мне знать, если он работает

+0

Спасибо, но все же три кнопки невидимы или они находятся за Imageview же как в RelativeLayout :( –

+0

отлично смотрится в моем случае .. Я отредактировал ответ, чтобы поставить гравитацию на первый линейный макет. Попробуйте с этим – virendrao

+0

Lol. Все-таки такие же, любые другие идеи?: D –

Смежные вопросы