问题描述
我一直很难阻止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.
我尝试在清单上进行更改,但没有成功.
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横幅会覆盖文本视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!