弹出软键盘时,adMob 横幅会覆盖文本视图 [英] adMob banner covers text view when soft keyboard pops up

查看:39
本文介绍了弹出软键盘时,adMob 横幅会覆盖文本视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直无法阻止 adMob 横幅沿软键盘滚动并覆盖我的文本视图......

I have been having troubles keeping an adMob banner from rolling up along the soft keyboard and covering my text views....

这是我要在 Android 中实现的目标的链接:http://bit.ly/myfoodcalc

This is the link to what I am trying to achieve in Android: http://bit.ly/myfoodcalc

我知道我的布局有点复杂,嵌套视图太多(可能)等等.

I know my layout is a little bit complex, too many nested views (maybe), etc.

我尝试在 Manifest 上更改内容,但没有成功.

I have tryed changing things on the Manifest without success.

为了让您更好地理解这里是子伪 XML(以及后面的完整 XML)...

For you to understand it better here is son pseudo XML (and the full XML later on the post)...

 <ScrollView>
      <Linear layout>
            <ImageView>
            <TableView>
                  <Several rows with a Edit Text widget>
            </TableView>
            </ImageView>
      </LinearLayout>
  </ScrollView>

  <FrameLayout>
       <ImageView>
  </FrameLayout>

这是我完整的 XML

<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:id="@+id/relativeLayout"
                    android:background="@drawable/backgroundwithtext">

    <ScrollView android:id="@+id/scrollView1" 
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent">

        <LinearLayout   android:id="@+id/linearLayout1" 
                        android:layout_width="fill_parent" 
                        android:layout_height="fill_parent" 
                        android:orientation="vertical" 
                        android:gravity="center_horizontal">

            <ImageView  android:id="@+id/imageView1" 
                        android:layout_width="wrap_content" 
                        android:src="@drawable/icon" 
                        android:layout_height="wrap_content"></ImageView>

            <TableLayout    android:id="@+id/tableLayout1" 
                            android:layout_height="wrap_content" 
                            android:layout_width="wrap_content" 
                            android:background="@drawable/backgroundsmallobj">

                <TableRow   android:id="@+id/tableRow1" 
                            android:layout_width="wrap_content" 
                            android:layout_height="wrap_content">

                    <TextView   android:text="TITLE" 
                                android:layout_width="wrap_content" 
                                android:layout_height="wrap_content" 
                                android:id="@+id/textView1">
                    </TextView>

                </TableRow>

                <TableRow   android:id="@+id/tableRow2" 
                            android:layout_width="wrap_content" 
                            android:layout_height="wrap_content">

                    <EditText   android:text="EditText" 
                                android:maxLines="1" 
                                android:id="@+id/editText2" 
                                android:layout_width="wrap_content"     
                                android:layout_height="wrap_content" 
                                android:imeOptions="actionNext">
                    </EditText>

                </TableRow>

                <TableRow   android:id="@+id/tableRow3" 
                            android:layout_width="wrap_content" 
                            android:layout_height="wrap_content">

                    <EditText   android:text="EditText" 
                                android:maxLines="1" 
                                android:id="@+id/editText3" 
                                android:layout_width="wrap_content" 
                                android:layout_height="wrap_content"
                                android:imeOptions="actionNext">
                    </EditText>

                </TableRow>

                <TableRow android:id="@+id/tableRow4" android:layout_width="wrap_content" android:layout_height="wrap_content">

                    <EditText   android:text="EditText" 
                                android:maxLines="1" 
                                android:id="@+id/editText4" 
                                android:layout_width="wrap_content" 
                                android:layout_height="wrap_content" 
                                android:imeOptions="actionNext">
                    </EditText>

                </TableRow>

                <TableRow   android:id="@+id/tableRow5" 
                            android:layout_width="wrap_content" 
                            android:layout_height="wrap_content">

                    <EditText   android:text="EditText"
                                android:maxLines="1" 
                                android:id="@+id/editText5" 
                                android:layout_width="wrap_content" 
                                android:layout_height="wrap_content" 
                                android:imeOptions="actionNext">
                    </EditText>

                </TableRow>

                <TableRow android:id="@+id/tableRow6" android:layout_width="wrap_content" android:layout_height="wrap_content">
                    <EditText android:text="EditText" android:maxLines="1" android:id="@+id/editText6" android:layout_width="wrap_content" android:layout_height="wrap_content" android:imeOptions="actionDone"></EditText>
                </TableRow>

                <TableRow android:id="@+id/tableRow7" android:layout_width="wrap_content" android:layout_height="wrap_content">
                    <Button android:id="@+id/button1" android:layout_height="wrap_content" android:text="Button" android:layout_width="wrap_content"></Button>
                </TableRow>


            </TableLayout>

        </LinearLayout>

    </ScrollView>

    <FrameLayout    android:id="@+id/frameLayout1" 
                    android:layout_height="wrap_content" 
                    android:layout_alignParentBottom="true" 
                    android:layout_width="fill_parent">

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

    </FrameLayout>

</RelativeLayout>

推荐答案

您可以更改键盘出现在广告上时的行为方式.进入您的 AndroidManifest.xml 并在带有 AdMob 横幅的活动标记中添加此属性.

You can change how the keyboard behaves when it appears over the Ad. Go into your AndroidManifest.xml and add this attribute in the activity tag with the AdMob banner.

android:windowSoftInputMode="adjustPan"

这将防止广告跳到键盘上方并隐藏输入.相反,它们将出现在键盘后面(隐藏).我不知道这是否违反 AdMob 政策,我只是提供一个解决方案.

This will prevent the ads from jumping above the keyboard and hiding the input. Instead, they will appear behind the keyboard (hidden). I don't know if this is against AdMob policy, I am just providing a solution.

这篇关于弹出软键盘时,adMob 横幅会覆盖文本视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆