9

पर EditText ओवरलैपिंग मेरी टुकड़ा में मैं एक scrollview के अंदर एक editText है और जब मैं मैं इसे इस तरह खोलने के लिए सेट पर क्लिक करें:कीबोर्ड क्लिक

getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); 

यह पहली बार खुलता से ठीक काम करता है, लेकिन जब मैं कीबोर्ड बंद करता हूं और इसे फिर से खोलता हूं, तो यह संपादन टेक्स्ट को ओवरलैप करता है, मैं संपादन टेक्स्ट को SOFT_INPUT_ADJUST_PAN मोड में हमेशा खोलने के लिए कैसे सेट कर सकता हूं?

एक्सएमएल:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:custom="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/alabaster"> 

    <TextView 
     android:id="@+id/semconexao" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="Verifique sua conexão com a internet" 
     android:gravity="center" 
     android:layout_marginTop="10dp" 
     android:visibility="gone"/> 


    <ScrollView 
     android:id="@+id/scroll" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_above="@+id/footer"> 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical"> 

      <RelativeLayout 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:visibility="visible"> 



       <com.android.volley.toolbox.NetworkImageView 
        android:id="@+id/imageInst" 
        android:layout_width="match_parent" 
        android:layout_height="200dp" 
        android:scaleType="centerCrop" 
        android:visibility="visible" /> 

       <com.retornar.utils.CircledNetworkImageView 
        android:id="@+id/thumbnail" 
        android:layout_width="@dimen/logo_maior" 
        android:layout_height="@dimen/logo_maior" 
        android:layout_marginLeft="20dp" 
        android:layout_marginTop="100dp" 
        android:adjustViewBounds="true" 
        android:scaleType="centerCrop"> 

       </com.retornar.utils.CircledNetworkImageView> 

       <ImageView 
        android:id="@+id/more" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/ic_amp" 
        android:visibility="gone" 
        android:layout_alignParentBottom="true" 
        android:layout_alignParentRight="true" 
        android:layout_alignParentEnd="true" /> 

      </RelativeLayout> 


      <TextView 
       android:id="@+id/retornarTitulo" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/imageInst" 
       android:layout_marginTop="20dp" 
       android:gravity="center" 
       android:padding="10dp" 
       android:text="@string/retornarTitulo" 
       android:textColor="@color/armadillo" 
       android:textSize="@dimen/text2" /> 


      <TextView 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/retornarTitulo" 
       android:gravity="center" 
       android:padding="10dp" 
       android:text="@string/retornar" 
       android:textColor="@color/armadillo" 
       android:textSize="@dimen/text1" /> 

      <include layout="@layout/valores" /> 


      <EditText 
       android:id="@+id/campovalor" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="60dp" 
       android:layout_marginLeft="10dp" 
       android:layout_marginRight="10dp" 
       android:layout_marginTop="10dp" 
       android:background="@drawable/shadoweditext" 
       android:gravity="center" 
       android:hint="ou entre com um valor" 
       android:imeOptions="actionDone" 
       android:inputType="numberDecimal" 
       android:padding="10dp" 
       android:singleLine="true" /> 


      <View 
       android:layout_width="match_parent" 
       android:layout_height="1dp" 
       android:layout_marginLeft="10dp" 
       android:layout_marginRight="10dp" 
       android:layout_marginTop="20dp" 
       android:background="@color/gray" /> 

      <TextView 
       android:id="@+id/propText" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="30dp" 
       android:layout_marginTop="20dp" 
       android:gravity="center" 
       android:padding="10dp" 
       android:text="Propósito em destaque" 
       android:textColor="@color/armadillo" 
       android:textSize="@dimen/text2" 
       android:visibility="gone" /> 

      <include layout="@layout/inst_prop" /> 

      <ImageView 
       android:id="@+id/maisprop" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" 
       android:layout_marginTop="20dp" 
       android:src="@drawable/ic_proposito" 
       android:visibility="gone" /> 

      <TextView 
       android:id="@+id/maisproptext" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="80dp" 
       android:layout_marginTop="10dp" 
       android:gravity="center" 
       android:text="Mais propósitos" 
       android:textColor="@color/armadillo" 
       android:visibility="gone" /> 

     </LinearLayout> 
    </ScrollView> 

    <TextView 
     android:id="@+id/ret" 
     fontPath="fonts/Avenir-Bold.ttf" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:alpha="0.9" 
     android:background="@color/blumine" 
     android:gravity="center" 
     android:padding="15dp" 
     android:text="DOAR" 
     android:textColor="@color/white" /> 

</RelativeLayout> 
+0

मैं तुम्हें अभिभावक के रूप में scrollview जोड़ने की जरूरत है लगता है लेआउट के बाद। आपका कोड काम कर सकता है। [यह] (http://stackoverflow.com/questions/8000795/android-keyboard-overlaps-with-the-edittext-with-printscreens) लिंक आपको – pRaNaY

+0

में मदद करता है क्या आपने इसे मैनिफेस्ट में सेट करने का प्रयास किया है? – zgc7009

+0

@ zgc7009 मैं एक टुकड़े का उपयोग करके ऐसा कैसे कर सकता हूं? – AND4011002849

उत्तर

14

PAN बजाय RESIZE स्थापना के बारे में क्या? आप अपने EditText को SoftKeyboard से ऊपर रखने में सक्षम होंगे। इस प्रकार का प्रयास करें:

getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); 

हालांकि, बजाय रनटाइम पर ऐसा करने का, आप इसे manifest में एक Activity(पैरेंट) विशेषता के रूप में सेट कर सकते हैं। यह भी अपने टुकड़ा (बच्चे) में संभाला जाएगा:

<activity 
    android:name=".NameActivity" 
    android:label="@string/app_name" 
    android:windowSoftInputMode="stateAlwaysHidden|adjustResize"> 

फिर, जैसा कि आप देख सकते हैं, EditText SoftKeyboard ऊपर है, लेकिन अपने लेआउट से, आप एक TextViewandroid:layout_alignParentBottom="true" साथ विशेषता है जो ओवरलैप होगा EditText:

1_screenshot_overlap_resize

इस व्यवहार को रोकने के लिए, अभी पिछले TextView ऊपर ScrollView इस प्रकार सेट:

<ScrollView 
    android:id="@+id/scroll" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_above="@+id/ret"> <!-- instead of "footer" --> 

और आप निम्न परिणाम प्राप्त होगा:

2_screenshot_no_overlap_resize

+0

यही है, धन्यवाद दोस्त! – AND4011002849

+1

@Filo क्यों फोन करके नहीं BottomSheetFragment में काम नहीं कर एक ही कोड करता है * getDialog() GetWindow() setSoftInputMode (WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);।। * Oncreateview –

5

, इस प्रयास करें अपने AndroidManifest.xml गतिविधि में इस कोड को जोड़ना

android:windowSoftInputMode="adjustPan" 
+0

में मैं चाहता हूँ सभी समस्याओं को हल किया जा सकता है वह आसानी से! धन्यवाद –

संबंधित मुद्दे