2015-10-09 23 views
1

我有一個活動(即Act.A),它開始另一個活動(Act.B)浮動Act.A上面,具有以下樣式集:編輯文本內浮動活動不會立即更新後鍵入

在Act.B的onCreate(savedInstanceState):

requestWindowFeature(Window.FEATURE_NO_TITLE); 

在styles.xml:

<style name="Theme.AppCompat.Light.NoTitle" parent="@style/Theme.AppCompat.Light"> 
    <item name="windowNoTitle">true</item> 
    <item name="windowActionBar">false</item> 
    <item name="android:windowFullscreen">false</item> 
    <item name="android:windowContentOverlay">@null</item> 
    <item name="android:windowBackground">@android:color/transparent</item> 
    <item name="android:windowIsTranslucent">true</item> 
    <item name="android:backgroundDimEnabled">true</item> 
</style> 

在Act.B,存在具有一個EditText的片段。在片段的onActivityCreated,我展示了軟鍵盤使用下面的代碼行:

edittext.requestFocus(); 
InputMethodManager inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); 
inputMethodManager.showSoftInput(edittext, 0); 

這裏是我的EditText上

  <EditText 
       android:id="@+id/phone_number" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:background="@null" 
       android:focusable="true" 
       android:focusableInTouchMode="true" 
       android:fontFamily="fonts/avenir-light.ttf" 
       android:hint="@string/sms_send_code_number_hint" 
       android:imeOptions="actionDone" 
       android:inputType="phone" 
       android:maxLines="1" 
       android:padding="5dp" 
       android:singleLine="true" 
       android:textColorHint="@color/sms_verification_edittext_grey" 
       android:textSize="16sp" /> 

XML軟鍵盤顯示,光標是裏面的EditText上。然而,在按下軟鍵盤上的按鍵時,edittext不會立即更新。只有在我按下後退按鈕解除軟鍵盤操作後,編輯文本纔會更新爲正確的文本。

我還注意到,在顯示鍵盤時,片段中的其他UI不會立即更新。然而,當我解僱軟鍵盤時UI將被更新。

任何提示將不勝感激。 thx提前。

回答

0

經過進一步調查,我發現它與上述代碼無關。

問題是由於自定義linearLayout自定義包含edittext的邊緣周圍的圓角。所以在我實現另一種繪製圓角的方法後,它工作正常。

相關問題