这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="myID"
ads:loadAdOnCreate="true" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageButton
android:id="@+id/search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:contentDescription="@string/search_contentDescription"
android:src="@android:drawable/ic_menu_search" />
<AutoCompleteTextView
android:id="@+id/edit"
android:imeOptions="actionSearch"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/search"
android:focusable="true"
android:hint="@string/edit_hint"
android:singleLine="true" />
<WebView
android:id="@+id/result"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/edit" />
</RelativeLayout>
</LinearLayout>
我的网站广告目前位于顶部。如何将其移至WebView的底层?将WebView的android:layout_height
更改为wrap_content
不是我想要的。 WebView的高度应垂直填充到最大值。
答案 0 :(得分:1)
为什么你不只是在你的相对布局之后放置你的adView:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageButton
android:id="@+id/search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:contentDescription="@string/search_contentDescription"
android:src="@android:drawable/ic_menu_search" />
<AutoCompleteTextView
android:id="@+id/edit"
android:imeOptions="actionSearch"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/search"
android:focusable="true"
android:hint="@string/edit_hint"
android:singleLine="true" />
<WebView
android:id="@+id/result"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/edit" />
</RelativeLayout>
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="myID"
ads:loadAdOnCreate="true" />
</LinearLayout>
如果它不起作用,您可以通过RelativeLayout更改LinearLayout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="myID"
ads:loadAdOnCreate="true"
android:layout_alignParentBottom="true"/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/adView" >
<ImageButton
android:id="@+id/search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:contentDescription="@string/search_contentDescription"
android:src="@android:drawable/ic_menu_search" />
<AutoCompleteTextView
android:id="@+id/edit"
android:imeOptions="actionSearch"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/search"
android:focusable="true"
android:hint="@string/edit_hint"
android:singleLine="true" />
<WebView
android:id="@+id/result"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/edit" />
</RelativeLayout>
</RelativeLayout>
答案 1 :(得分:0)
将您的RelativeLayout
更改为LinearLayout
并使用
android:layout_height="0dp"
android:layout_weight="1"
<{1}}和LinearLayout
中的
答案 2 :(得分:0)
执行类似
的操作<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageButton
android:id="@+id/search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="@android:drawable/ic_menu_search" />
<AutoCompleteTextView
android:id="@+id/edit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/search"
android:focusable="true"
android:hint=" string/edit_hint"
android:imeOptions="actionSearch"
android:singleLine="true" />
<WebView
android:id="@+id/result"
android:layout_width="fill_parent"
android:layout_height="350dp"
android:layout_below="@id/edit" />
</RelativeLayout>
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="myID"
ads:loadAdOnCreate="true" />
</LinearLayout>