2016-02-10 62 views
-1

點擊編輯文本軟鍵盤已打開,但編輯文本並不完全可見。類似於點擊表情符號圖標,表情符號面板打開但編輯文本不可見。屏幕截圖給出如下:當軟鍵盤處於打開狀態時,EditText並不完全可見

Screen shot 1

Screen shot 2

Screen shot 3

代碼:

// On clicking the edit text Emoji panel will be hidden 
    edMessage.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      hideEmoji = true; 
      hideEmojiPopUp(hideEmoji); 
      showKeyboard(edMessage); 
     } 
    }); 

// Hiding the FrameLayout containing the list of Emoticons 
public void hideEmojiPopUp(boolean hideEmoji) { 
    FrameLayout frameLayout = (FrameLayout) findViewById(R.id.emojicons); 
    frameLayout.setVisibility(View.GONE); 
} 

//Show the soft keyboard 
public void showKeyboard(EditText editText) { 
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 
    imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT); 
    //setHeightOfEmojiEditText(); 
} 

的Manifest.xml

<activity 
     android:name=".activity.SingleChatActivity" 
     android:windowSoftInputMode="adjustResize"> 
    </activity> 

activity_singlechat.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/bg_single_chat" 
    android:orientation="vertical" 
    android:weightSum="1"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbarSingleChat" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="#09436B" 
     android:elevation="6dp" 
     android:minHeight="?attr/actionBarSize" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
     app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 

    <ListView 
     android:id="@+id/lv_message" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight=".90" 
     android:divider="@null" 
     android:stackFromBottom="true" 
     android:transcriptMode="alwaysScroll"></ListView> 

    <com.rockerhieu.emojicon.EmojiconEditText 
     android:id="@+id/edtMessage" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_gravity="bottom" 
     android:layout_weight=".10" 
     android:background="#FFFFFF" 
     android:drawableLeft="@drawable/emoticons" 
     android:drawablePadding="@dimen/padding10" 
     android:drawableRight="@drawable/send" 
     android:hint="Type your message ..." 
     android:paddingBottom="@dimen/padding10" 
     android:paddingLeft="@dimen/padding10" 
     android:paddingRight="@dimen/padding10" 
     android:paddingTop="@dimen/padding10" /> 

    <View 
     android:id="@+id/view" 
     android:layout_width="wrap_content" 
     android:layout_height="10dp" 
     android:visibility="gone" /> 

    <FrameLayout 
     android:id="@+id/emojicons" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight=".00" 
     android:visibility="gone" /> 
</LinearLayout> 

請幫我解決這個問題。

編輯代碼:

我已經改變了xml文件如下:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/bg_single_chat" 
    android:orientation="vertical" 
    android:weightSum="1"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbarSingleChat" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="#09436B" 
     android:elevation="6dp" 
     android:minHeight="?attr/actionBarSize" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
     app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 

    <ListView 
     android:id="@+id/lv_message" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight=".90" 
     android:divider="@null" 
     android:stackFromBottom="true" 
     android:transcriptMode="alwaysScroll"></ListView> 


    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 

      <com.rockerhieu.emojicon.EmojiconEditText 
       android:id="@+id/edtMessage" 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_gravity="bottom" 
       android:layout_weight=".10" 
       android:background="#FFFFFF" 
       android:drawableLeft="@drawable/emoticons" 
       android:drawablePadding="@dimen/padding10" 
       android:drawableRight="@drawable/send" 
       android:hint="Type your message ..." 
       android:paddingBottom="@dimen/padding10" 
       android:paddingLeft="@dimen/padding10" 
       android:paddingRight="@dimen/padding10" 
       android:paddingTop="@dimen/padding10" /> 

      <FrameLayout 
       android:id="@+id/emojicons" 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_weight=".00" 
       android:visibility="gone" /> 
     </LinearLayout> 
    </ScrollView> 
</LinearLayout> 

我得到如下畫面:

screen shot 4

Screen shot 5

enter image description here

現在編輯短信完全是可見的,但屏幕的佈局工作不正常的EditText上的文字應該是在屏幕的底部。但我得到下面的EditText一些空間。

回答

1

在您的xml中更改或添加ScrollView作爲您的EditText父級佈局。

<ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
    <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 
     <EditText 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"/> 
    </LinearLayout> 

</ScrollView> 

,並添加到您的活動的AndroidManifest

android:configChanges="keyboardHidden|orientation|screenSize" 
android:windowSoftInputMode="stateHidden|adjustResize" 
+1

我已經改變了xml文件按照烏拉圭回合的指導。現在EDITTEXT在軟鍵盤上,但我的文件佈局不顯示不正確正常工作.EditText應該在屏幕的底部。但我得到editext下面的一些空間。請參閱我編輯的XML文件,並幫助我解決這個問題。 –

+0

我現在在手機上,無法查看我的語法是否正確。在scrollview中將adjustviewbounds添加爲true。 –

相關問題