2012-05-15 18 views
13

मैं कुछ क्षेत्रों के साथ एक दृश्य (नाम, ईमेल, पासवर्ड, रजिस्टर बटन):कुंजीपटल दिखाई देने पर एंड्रॉइड व्यू स्क्रॉल करने योग्य कैसे बनाएं?

<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <ViewFlipper 
     android:id="@+id/viewflipper" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 

     //Layouts 

    </ViewFlipper> 

</ScrollView> 

जब मैं एक edittext क्षेत्र ध्यान देते हैं, कुंजीपटल प्रकट होता है और दृश्य पर कम क्षेत्रों डालने कर रहा है। तो जब कीबोर्ड मौजूद होता है तो मैं उन्हें नहीं देख सकता। मैं जानना चाहता हूं कि दृश्य को स्क्रॉल करने योग्य कैसे बनाया जाए ताकि मैं निचले फ़ील्ड देख सकूं। और इसके अतिरिक्त, ध्यान केंद्रित क्षेत्र को दृश्यमान बनाने के लिए स्वचालित रूप से दृश्य स्क्रॉल कैसे करें।

उत्तर

37

आप AndroidManifest.xml फ़ाइल में अपनी गतिविधि के लिए android:windowSoftInputMode="adjustResize" विशेषता शामिल करने के लिए की जरूरत है - और उसके बाद एंड्रॉयड आपके लिए अपने आप का आकार बदलने के लिए क्या करना चाहिए:

<ScrollView 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 

<ViewFlipper 
    android:id="@+id/viewflipper" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" > 
    <ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:id="@+id/scroll_container"> 
     //Layouts 
    </ScrollView> 


</ViewFlipper> 

:

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

वास्तव में इसे "एडजस्टपैन | एडजस्ट रीसाइज" पर सेट किया गया था। एडजस्टन को हटाकर इसे काम किया। धन्यवाद! – Alexis

0

आप इस की कोशिश की है

6

मैंने सरल XML फ़ाइल बनाई है, आशा है कि यह वही है जो आप ढूंढ रहे हैं।

चरण 1। कुंजी-पैड दिखाई देने पर आप स्क्रॉल कर सकते हैं।

चरण 2। जब आप टेक्स्ट-फील्ड पर क्लिक करते हैं तो यह फोकस/उपरोक्त कीपैड पर आ जाएगा।

<ScrollView android:id="@+id/ScrollView01" 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:fillViewport="true" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:weightSum="1.0" 
    android:layout_height="match_parent" 
    android:focusable="true" 
    android:focusableInTouchMode="true" 
    android:id="@+id/l_layout"> 
    <EditText 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     android:id="@+id/editText1" 
     android:layout_marginTop="100dp"> 
     <requestFocus></requestFocus> 
    </EditText> 
    <EditText 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     android:id="@+id/editText2" 
     android:layout_marginTop="100dp"> 
     </EditText> 
    </LinearLayout> 
</ScrollView> 
+0

मुझे स्क्रॉलव्यू के साथ समस्या हो रही थी और fillViewport बस मुझे चाहिए। – AlexBrand

0

मेरे मामले में @ एलेक्स जी समाधान काम नहीं कर रहा था। इसलिए मैंने

<RelativeLayout 
    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="wrap_content" 
    > 

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/registration_scroll_view" 
    android:layout_alignParentTop="true" 
    android:layout_above="@+id/btn_register_submit" 
    > 

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

     <!--This comment will be replaced 
      by your focusable views--> 

    </LinearLayout> 
</ScrollView> 

<Button 
    android:id="@+id/btn_register_submit" 
    android:layout_width="match_parent" 
    android:layout_height="50dp" 
    android:layout_alignParentBottom="true" 
    android:background="@drawable/form_action_button_green" 
    android:gravity="center" 
    android:text="@string/submit" 
    /> 

</RelativeLayout> 
संबंधित मुद्दे