2016-06-29 1 views

답변

2

당신은

public class CustomPopup extends PopupWindow { 
    Context mContext; 
    View rootView; 

    public CustomPopup(View rootView, Context mContext){ 
     super(mContext); 
     this.mContext = mContext; 
     this.rootView = rootView; 
     View customView = createCustomView(); 
     setContentView(customView); 
     setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); 
     setSize(250, LayoutParams.MATCH_PARENT); 
    } 

    private View createCustomView(){ 
     LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
     View view = inflater.inflate(R.layout.custom_popup, null, false); 

     return view; 
    } 

    public void setSize(int width, int height){ 
     setWidth(width); 
     setHeight(height); 
    } 

} 

이 그런 다음 SoftKeyboard 클래스

CustomPopup popupWindow; 

public View onCreateInputView() { 
     final View root = getLayoutInflater().inflate(R.layout.input, null); 

     popupWindow = new CustomPopup(root, this); 

     return root; 
} 

이을에서 사용 PopupWindow 확장하는 클래스를 만들어야합니다 팝업을 표시하는 방법입니다. mInputView는 keyboardView 변수입니다.

private void showPopup() { 
     int height = mInputView.getHeight(); 
     popupWindow.setSize(LayoutParams.MATCH_PARENT, height); 
     popupWindow.showAtLocation(mInputView.getRootView(), Gravity.BOTTOM, 0, 0); 
     final InputMethodManager mInputMethodManager = (InputMethodManager) getBaseContext() 
       .getSystemService(Context.INPUT_METHOD_SERVICE); 
     mInputMethodManager.showSoftInput(mInputView, 0); 
    } 
+0

답변 해 주셔서 감사합니다! –

관련 문제