मैं "रिप्लाइड बाय:" अनुभाग में डेटा देखने के लिए स्क्रीन को नीचे स्क्रॉल नहीं कर सकता। मैं अपने लेआउट को कैसे स्क्रॉल कर सकता हूं?
मैं "रिप्लाइड बाय:" अनुभाग में डेटा देखने के लिए स्क्रीन को नीचे स्क्रॉल नहीं कर सकता। मैं अपने लेआउट को कैसे स्क्रॉल कर सकता हूं?
जवाबों:
बस एक अंदर सभी लपेटो 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>
जैसा कि डेविड हेडलंड ने कहा, 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>
संबंधित लेआउट के साथ स्क्रॉल दृश्य का उपयोग करने के लिए:
<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>
बस स्क्रॉल के अंदर वह सब लपेटें
<?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>
अगर आपको ऊपर लिखी हुई चीज़ करने के बाद भी स्क्रॉल नहीं मिला है तो .....
सेट करें android:layout_height="250dp"
या आप कह सकते हैं कि कोई संख्यात्मक मान xdp
कहाँ x
हो सकता है।
ScrollView
क्या केवल एक ही बच्चा हो सकता है, इसलिए यदि आपके पास वर्तमान में बहुत सारे विचार हैं, तो आपको उन्हें एक दृश्य समूह में लपेटने की आवश्यकता है (कहते हैंLinearLayout
)