开发者

RelativeLayout problem. ImageView scroll up when keyboard shown

开发者 https://www.devze.com 2023-04-08 22:22 出处:网络
I\'m trying to show a ImageView under a AdView like image 2. The problem is where the EditText is active, the keyboard is shown and if the AdView is loaded, all works perfect, but when the AdView isn\

I'm trying to show a ImageView under a AdView like image 2. The problem is where the EditText is active, the keyboard is shown and if the AdView is loaded, all works perfect, but when the AdView isn't loaded, the ImageView scroll up out of the screen like image 1

Here is my xml layout:

<?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:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:gravity="top">

<com.google.ads.AdView android:layout_width="wrap_content"
    android:id="@+id/adView" android:layout_height="wrap_content"
    ads:adUnitId="XXXXXXXXX" ads:adSize="BANNER" ads:loadAdOnCreate="true"
    android:layout_alignParentTop="true" android:layout_centerHorizontal="true" />

<ImageView android:src="@drawable/frame008" android:id="@+id/imageView1"
    android:scaleType="centerInside" android:layout_height="wrap_content"
    android:adjustViewBounds="true" android:focusable="false"
    android:layout_width="match_parent" android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true" android:layout_marginTop="50dip"></ImageView>

The EditText and Submit button:

<RelativeLayout android:id="@+id/linearLayout4"
    andr开发者_如何学编程oid:orientation="horizontal" android:layout_height="wrap_content"
    android:layout_width="fill_parent" android:layout_centerHorizontal="true"
    android:layout_alignParentBottom="true">
    <Button android:text="Submit" android:id="@+id/button2"
        android:onClick="submit" android:layout_height="wrap_content"
        android:layout_width="wrap_content" android:layout_alignParentRight="true"></Button>
    <EditText android:layout_width="wrap_content" android:id="@+id/editText1"
        android:layout_height="wrap_content" android:layout_alignParentLeft="true"
        android:layout_toLeftOf="@id/button2">
        <requestFocus></requestFocus>
    </EditText>

</RelativeLayout>

Thanks for your time!!

RelativeLayout problem. ImageView scroll up when keyboard shown

RelativeLayout problem. ImageView scroll up when keyboard shown


The code snippet below should be what you need to position the views as you want:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout >

    <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_alignParentTop="true" />

    <RelativeLayout 
        android:id="@+id/linearLayout4"
        android:layout_alignParentBottom="true">
    </RelativeLayout>

    <ImageView 
        android:layout_below="@+id/adView"
        android:layout_above="@+id/linearLayout4">
    </ImageView>

</RelativeLayout>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号