今天项目中需要用到设置输入法的位置和大小的,下面的文章非常不错,
但是需要自己设置好这个pf,df参数
转自:https://blog.youkuaiyun.com/jianguo_liao19840726/article/details/43758657
PhoneWindowManager.java
else if (attrs.type == TYPE_INPUT_METHOD) {
pf.left = df.left = of.left = cf.left = vf.left = 550;//mDockLeft; pf.top = df.top = of.top = cf.top = vf.top = 180;//mDockTop;
pf.right = df.right = of.right = cf.right = vf.right = 1020;//mDockRight;
pf.bottom = df.bottom = of.bottom = 400;//mUnrestrictedScreenTop + mUnrestrictedScreenHe
<pre name="code" class="html">cf.bottom = vf.bottom = 490;//mStableBottom;
//attrs.gravity = Gravity.BOTTOM;
/**
* Global environment configurations for showing soft keyboard and candidate
* view. All original dimension values are defined in float, and the real size
* is calculated from the float values of and screen size. In this way, this
* input method can work even when screen size is changed.
*/
public class Environment {
public void onConfigurationChanged(Configuration newConfig, Context context) {
if (mConfig.orientation != newConfig.orientation) {
WindowManager wm = (WindowManager) context
.getSystemService(Context.WINDOW_SERVICE);
Display d = wm.getDefaultDisplay();
// mScreenWidth = d.getWidth();
mScreenWidth = 500;
mScreenHeight = d.getHeight();
本文详细介绍如何在项目中设置输入法的位置和大小,通过调整pf,df参数实现精确控制。文章提供了PhoneWindowManager.java代码示例,展示了如何根据屏幕尺寸调整输入法显示区域。
1203

被折叠的 条评论
为什么被折叠?



