2014-04-23 1 views
1

소프트 키보드에서 보내기 옵션을 사용하여 여러 줄의 텍스트를 보관하기 위해 Custom EditText를 사용하고 있습니다. 그것은 잘 작동하지만 내 탭 막대는 키보드와 함께 상단으로 이동합니다. 내 매니 페스트 파일에서 다음을 사용했습니다.TabBar가 Custom EditText를 사용하여 소프트 키보드와 함께 이동합니다.

android:windowSoftInputMode="adjustPan" 
    android:windowSoftInputMode="adjustResize" 

정상적인 EditText에서는 정상적으로 작동합니다. 하지만 CustomEditText를 사용하고 있다면 실패합니다.

<com.sample.helpers.CustomEditText 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     android:hint="Description" 
     android:paddingLeft="10dp" 
     android:paddingRight="10dp" 
     android:textSize="16dp" 
     android:id="@+id/et_description" 

     /> 

내 사용자 지정 글고 클래스 :

public class CustomEditText extends EditText { 



public CustomEditText(Context context, AttributeSet attrs) { 
    super(context, attrs); 
    // TODO Auto-generated constructor stub 
} 

public CustomEditText(Context context) { 
    super(context); 
    // TODO Auto-generated constructor stub 
} 

public CustomEditText(Context context, AttributeSet attrs, int defStyle) { 
    super(context, attrs, defStyle); 
    // TODO Auto-generated constructor stub 
} 

@Override 
public InputConnection onCreateInputConnection(EditorInfo outAttrs) { 
    InputConnection connection = super.onCreateInputConnection(outAttrs); 
    int imeActions = outAttrs.imeOptions&EditorInfo.IME_MASK_ACTION; 
    if ((imeActions&EditorInfo.IME_ACTION_NEXT) != 0) { 
     // clear the existing action 
     outAttrs.imeOptions ^= imeActions; 
     // set the DONE action 
     outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT; 
    } 
    if ((outAttrs.imeOptions&EditorInfo.IME_FLAG_NO_ENTER_ACTION) != 0) { 
     outAttrs.imeOptions &= ~EditorInfo.IME_FLAG_NO_ENTER_ACTION; 
    } 
    return connection; 
} 

} 

스크린 샷 :

enter image description here

내 XML이다 0

그래서 처리 방법을 안내해주세요.

+0

당신은 어떤 솔루션을 얻었 는가? bcz 나는 또한 같은 문제에 직면하고있다 ...? – Developer

+0

@ 개발자 http://stackoverflow.com/questions/8881324/android-keyboard-puts-tab-bar-on-top –

답변

1

키 보드 가까이 얻을 때 다시 표시 한 후 키보드가 열리면,이 레이아웃을 숨길이 시도 할 수 Java 코드

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); 
-1

이보십시오. 여기

/*Hide button when keyboard is open*/ 
view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { 
    @Override 
    public void onGlobalLayout() { 
     Rect r = new Rect(); 
     view.getWindowVisibleDisplayFrame(r); 

     int heightDiff = view.getRootView().getHeight() - (r.bottom - r.top); 

     if (heightDiff > 244) { // if more than 100 pixels, its probably a keyboard... 
      //ok now we know the keyboard is up... 
      buttonLayout.setVisibility(View.GONE); 


     } else { 
      //ok now we know the keyboard is down... 
      buttonLayout.setVisibility(View.VISIBLE); 


     } 
    } 
}); 

체크 - https://stackoverflow.com/a/35267926/2128166

관련 문제