Adview显示在软键盘顶部
我刚刚将 AdWhirl 集成到我的应用程序中。我将 AdWhirl 视图设置为显示在主要活动布局的底部。我的主布局上有几个 EditText 框,当应用程序首次启动时,单击文本框通常会显示软键盘。但是,当我转到另一个活动并返回到我的主要活动时,然后单击 EditText,软键盘会弹出,顶部显示 AdWhirl 视图,覆盖我的 EditText 框。我已经为此苦苦挣扎了好几天。任何帮助将不胜感激。
我在清单中为所有活动定义了 android:windowSoftInputMode="adjustPan" 。
这是我的 main.xml 布局:
<RelativeLayout android:id="@+id/RelativeLayout01"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView android:id="@+id/ImageView02"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="@drawable/other_bg_small" android:layout_weight="1"/>
<ImageView android:id="@+id/ImageView01"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:background="@drawable/banner" android:layout_alignParentTop="true"
android:paddingBottom="30dip"/>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:stretchColumns="1" android:gravity="center" android:id="@+id/table01"
android:layout_below="@id/ImageView01" >
... Table stuff
</TableLayout>
<LinearLayout android:layout_width="fill_parent"
android:id="@+id/ad_layout" android:layout_height="wrap_content"
android:gravity="bottom" android:layout_alignParentBottom="true"
android:layout_alignBottom="@+id/RelativeLayout01" android:layout_weight="1">
<com.adwhirl.AdWhirlLayout android:id="@+id/adwhirl_layout"
android:layout_width="fill_parent" android:layout_height="wrap_content"/>
</LinearLayout>
</RelativeLayout>
I have just integrated AdWhirl into my app. I have the AdWhirl view set to show up on the bottom of the layout of my main activity. I have a few EditText boxes on my main layout and when the app first launches clicking the text boxes displays the soft keyboard normally. However when I go to another activity and back to my main activity, then click the EditText the soft keyboard pops up with the AdWhirl view on top, covering my EditText box. I have been struggling with this for days. Any help would be appreciated.
I have android:windowSoftInputMode="adjustPan" defined in my manifest for all activities.
Here is my main.xml layout:
<RelativeLayout android:id="@+id/RelativeLayout01"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView android:id="@+id/ImageView02"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="@drawable/other_bg_small" android:layout_weight="1"/>
<ImageView android:id="@+id/ImageView01"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:background="@drawable/banner" android:layout_alignParentTop="true"
android:paddingBottom="30dip"/>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:stretchColumns="1" android:gravity="center" android:id="@+id/table01"
android:layout_below="@id/ImageView01" >
... Table stuff
</TableLayout>
<LinearLayout android:layout_width="fill_parent"
android:id="@+id/ad_layout" android:layout_height="wrap_content"
android:gravity="bottom" android:layout_alignParentBottom="true"
android:layout_alignBottom="@+id/RelativeLayout01" android:layout_weight="1">
<com.adwhirl.AdWhirlLayout android:id="@+id/adwhirl_layout"
android:layout_width="fill_parent" android:layout_height="wrap_content"/>
</LinearLayout>
</RelativeLayout>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试为您的 EditText 框设置 onFocusChangeListener 。当它们获得焦点时,将 AdWhirl 视图可见性设置为 View.INVISIBLE,这样它就不会遮挡文本框,然后在失去焦点时将其设置回可见。
Try setting a onFocusChangeListener to your EditText boxes. When they get focus, set the AdWhirl view visibility to View.INVISIBLE so it doesn't obstruct the textboxes and then set it back to visible once focus is lost.
我尝试设置 android:windowSoftInputMode="adjustPan"。
它隐藏了 adMob 横幅但也隐藏了 EdiText。
我也尝试了接受的答案,但编辑文本可以在不打开键盘的情况下获得焦点。
所以我找到的解决方案是在键盘打开时隐藏 adMob 横幅。
我学会了如何检测键盘是否打开 此处。
这是我的解决方案:
I tried setting android:windowSoftInputMode="adjustPan".
it hides the adMob banner but also the EdiText.
I also tried the accepted answer, but the edittext can get focus without the keyboard opens.
So the solution I found is to hide the adMob banner when the keyboard opens.
I learned how to detect if the keyboard opens here.
and here is my solution: