使用popwindow制作弹出框与获得焦点弹出软键盘
生活随笔
收集整理的這篇文章主要介紹了
使用popwindow制作弹出框与获得焦点弹出软键盘
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
如果是聲明一各類
public class VideoFilterDialog extends PopupWindow 那么在構(gòu)造方法中添加: conentView = inflater.inflate(R.layout.video_popup_filter, null); this.setWidth(ViewGroup.LayoutParams.MATCH_PARENT); this.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); this.setContentView(conentView); 注意:上面的布局大小,直接使用了ViewGroup;因?yàn)檫@個(gè)是最上層的父布局,Linearlayout,Framlayout,Relativelayout都是繼承于它。也可以直接針對(duì)自己的布局使用Linearlayout,Framlayout,Relativelayout的 LayoutParams。彈出展示:
showAtLocation(parent, Gravity.NO_GRAVITY, x, y); parent是彈出框口的根布局。獲取焦點(diǎn)彈出軟鍵盤,并且將popwindow往上頂起:
this.setBackgroundDrawable(new BitmapDrawable()); this.setOutsideTouchable(false); this.setFocusable(true); //mEditInput.requestFocus(); this.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED); this.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); this.showAtLocation(CommentCons.mFatherView, Gravity.BOTTOM, 0, 0);說(shuō)白了popwindow實(shí)現(xiàn)自動(dòng)彈出軟鍵盤就是提供了
PopupWindow.INPUT_METHOD_NEEDED 方法,ACTIVITY中提供setSoftInputMode()方法,為何在fragment中提供 INPUT_METHOD_NEEDED? 參數(shù)。 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?總結(jié)
以上是生活随笔為你收集整理的使用popwindow制作弹出框与获得焦点弹出软键盘的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: volatile与synchronize
- 下一篇: popwindow 焦点问题,物理返回键