2010-09-29 13 views
69

मैं "द्वारा प्रतिस्थापित:" अनुभाग में डेटा देखने के लिए स्क्रीन को स्क्रॉल नहीं कर सकता। मैं अपना लेआउट स्क्रॉल करने योग्य कैसे बना सकता हूं?मेरे लेआउट को स्क्रॉल करने में सक्षम कैसे करें?

alt text

उत्तर

154

बस एक ScrollView अंदर सब लपेट:

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <!-- Here you put the rest of your current view--> 
</ScrollView> 

डेविड Hedlund ने कहा, ScrollView शामिल कर सकते हैं केवल एक आइटम ... इसलिए यदि आप कुछ इस तरह था:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <!-- bla bla bla--> 
</LinearLayout> 

आपको इसे बदलना होगा:

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
     <!-- bla bla bla--> 
    </LinearLayout> 
</ScrollView> 
+9

+1 के अंदर सभी कि लपेट दें। एक त्वरित नोट: एक 'स्क्रॉल व्यू' में केवल एक बच्चा हो सकता है, इसलिए यदि आपको जो मिला है वह बहुत सारे विचार हैं, तो आपको उन्हें एक व्यू समूह में लपेटने की आवश्यकता है (एक 'लीनियरलाउट' कहें –

+1

धन्यवाद @ डेविड हेडलंड –

+0

मेरी समस्या को ठीक करने के लिए कृपया मेरी मदद करें http://stackoverflow.com/questions/38588702/why-my-scrollview-not-working-properly – Karthi

29

सापेक्ष लेआउट के साथ पुस्तक दृश्य का उपयोग कर के लिए:

<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:fillViewport="true"> <!--IMPORTANT otherwise backgrnd img. will not fill the whole screen --> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:paddingBottom="@dimen/activity_vertical_margin" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:paddingTop="@dimen/activity_vertical_margin" 
     android:background="@drawable/background_image" 
    > 

    <!-- Bla Bla Bla i.e. Your Textviews/Buttons etc. --> 
    </RelativeLayout> 
</ScrollView> 
+0

व्यूपोर्ट टैग क्या है –

0

आप भी कर रही है ऊपर क्या लिखा है के बाद से स्क्रॉल नहीं जा सके थे, तो .....

सेट android:layout_height="250dp" या आप कह सकते हैं xdp जहां x कोई संख्यात्मक मूल्य हो सकता है।

1

बस एक scrollview

<?xml version="1.0" encoding="utf-8"?> 

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.ruatech.sanikamal.justjava.MainActivity"> 
<!-- Here you put the rest of your current view--> 
</ScrollView> 
संबंधित मुद्दे