我已经制作了一个简单的webview应用程序,我得到了横幅,但我希望横幅在底部。我已经尝试了很多,但我不能让它工作。希望有人可以帮助我。
这是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"
android:background="#000000"
android:id="@+id/mainLayout">
<com.google.android.gms.ads.AdView android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="ca-app-pub-9380760713574559/3453176828"
ads:adSize="SMART_BANNER"/>
<ImageView android:id="@+id/splashScreen"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:visibility="visible"
android:src="@drawable/splash"
/>
<WebView
android:id="@+id/mainWebView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="gone"
/>
</LinearLayout>
答案 0 :(得分:3)
我试过这个。希望它可以帮到你
<?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:id="@+id/mainLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5"
android:orientation="vertical" >
<ImageView
android:id="@+id/splashScreen"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="visible" />
<WebView
android:id="@+id/mainWebView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="bottom"
android:orientation="vertical" >
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="ca-app-pub-9380760713574559/3453176828" >
</com.google.android.gms.ads.AdView>
</LinearLayout>
</LinearLayout>
答案 1 :(得分:0)
在com.google.android.gms.ads.AdView标记
中添加以下属性android:layout_alignParentBottom="true"
答案 2 :(得分:0)
AdView.LayoutParams adViewParams = new AdView.LayoutParams(AdView.LayoutParams.WRAP_CONTENT,AdView.LayoutParams.WRAP_CONTENT); adViewParams.addRule(AdView.ALIGN_PARENT_BOTTOM); adViewParams.addRule(AdView.CENTER_HORIZONTAL); layout.addView(adMobView,adViewParams);