Make webview fill_parent stay above the bottom image in Android [duplicate]
I have following things layed out in my xml file:
- Webview
- Bottom image/ Admob
Since I wanted my Admob to be displayed at the bottom, I chose two different layouts LinearLayout for Admob as suggested and RelativeLayout for other views.
Also, since I'm displaying splashscreen first and then webview, my logic goes such that I want both of them in a framelayout. My bottom image and Admob lay one above the other. So, my code goes as:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/app.news"
android:layout_width="wrap_content"
android:layout_height="fill_parent">
<FrameLayout
android:id="@+id/views"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:id="@+id/splash_screen"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="center"
android:src="@drawable/splash_screen"
android:visibility="visible"
/>
<WebView
android:id="@+id/webvw"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="fill_vertical"
android:scrollbars="none"
android:visibility="invisible"
/>
<ImageView
android:id="@+id/bottomImage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitEnd"
android:src="@drawable/开发者_开发知识库logo"
android:visibility="visible"
/>
</FrameLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:layout_alignBottom="@id/views"
>
<com.admob.android.ads.AdView
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
myapp:backgroundColor="#000000"
myapp:primaryTextColor="#FFFFFF"
myapp:secondaryTextColor="#CCCCCC"
myapp:testing="false"
/>
</LinearLayout>
</RelativeLayout>
I want webview to occupy all the space except for the bottom image, I'm not sure how to make it happen using webview height to be "fill_parent".
Try using a zero height and set gravity to 1:
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
精彩评论