2016-12-19 6 views
0

Здравствуйте, когда я пытаюсь загрузить мое приложение (WebView с AdView) и я вижу белый экран и ничего не происходит, это происходит, когда я пытаюсь получить AdView работатьAndroid студия белый экран при загрузке до

MainActivity.xml 
<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout     
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:ads="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true" 
tools:context="danilkp1234.com.pokemondamagecalculator.MainActivity"> 
<include layout="@layout/content_main" /> 
<com.google.android.gms.ads.AdView 
android:id="@+id/adView" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_alignParentTop="false" 
android:layout_centerHorizontal="true" 
android:layout_alignParentBottom="true" 
ads:adSize="BANNER" 
ads:adUnitId="@string/banner_ad_unit_id"> 

</com.google.android.gms.ads.AdView> 


<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_above="@id/adView" 
    android:layout_alignParentTop="true" 
    android:orientation="vertical"> 

    <WebView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/webview"> 
    </WebView> 
</LinearLayout> 



</android.support.design.widget.CoordinatorLayout> 

PLS помогите мне с этим, если вам нужна дополнительная информация eks build.gradle

+0

пожалуйста, [рассмотреть вопрос о поиске, как загружать объявления] (https://firebase.google.com/docs/admob/android/quick-start) –

ответ

0

Поскольку вы написали код веб-просмотра внизу с высотой и шириной как match_parent, он будет занимать весь экран. либо используйте параметр weight внутри LinearLayout с вертикальной ориентацией или используйте RelativeLayout с правилами выравнивания. Попробуйте это, замените код ниже 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" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    android:orientation="vertical" 
    tools:context="danilkp1234.com.pokemondamagecalculator.MainActivity"> 

    <include 
     layout="@layout/content_main" 
     android:layout_width="match_parent" 
     android:layout_height="50dp" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@id/adView" 
     android:layout_weight="1" 
     android:orientation="vertical"> 

     <WebView 
      android:id="@+id/webview" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"></WebView> 
    </LinearLayout> 

    <com.google.android.gms.ads.AdView 
     android:id="@+id/adView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     ads:adSize="BANNER" 
     ads:adUnitId="@string/banner_ad_unit_id"> 

    </com.google.android.gms.ads.AdView> 
</LinearLayout> 
+0

я get this error Ошибка: (20, 31) Ресурс не найден, который соответствует указанному имени (в 'layout_above' со значением '@ id/adView'). Ошибка: выполнение выполнено для задачи ': app: processDebugResources'. > com.android.ide.common.process.ProcessException: Не удалось выполнить aapt Ошибка: (20, 31) Ресурс не найден, который соответствует указанному имени (в 'layout_above' со значением '@ id/adView'). C: \ Users \ danie \ AndroidStudioProjects \ PokemonDamageCalculator \ app \ build \ intermediates \ res \ merged \ debug \ layout \ activity_main.xml C: \ Users \ danie \ AndroidStudioProjects \ PokemonDamageCalculator \ app \ src \ main \ res \ layout \ activity_main.xml – danilkp1234