কীভাবে আমার লেআউটটি নীচে স্ক্রোল করতে সক্ষম করবেন?


92

"জবাব দেওয়া:" বিভাগে ডেটা দেখতে আমি স্ক্রিনটি স্ক্রোল করতে পারছি না। আমি কীভাবে আমার লেআউটটিকে স্ক্রোলযোগ্য করতে পারি?

বিকল্প পাঠ

উত্তর:


203

এগুলি কেবল একটি অভ্যন্তরে আবদ্ধ করুন 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>

16
+1 একটি দ্রষ্টব্য নোট: ScrollViewএকটিতে কেবল একটি শিশু থাকতে পারে, তাই আপনি যা পেয়েছেন তা যদি এখন প্রচুর মত হয় তবে আপনাকে সেগুলি একটি LinearLayout
— দলে দলে আবদ্ধ করতে হবে

কীভাবে আমার সমস্যাটি সমাধান করবেন দয়া করে আমাকে স্ট্যাকওভারফ্লো.com
— কারথি

41

আপেক্ষিক বিন্যাসের সাথে স্ক্রোল ভিউ ব্যবহারের জন্য:

<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>

4
ভিউপোর্ট ট্যাগটি কী
— রুচির বড়োনিয়া

4

সমস্ত কিছু কেবল একটি স্ক্রোলভিউয়ের মধ্যে আবদ্ধ করুন

<?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>

1

হ্যাঁ, এটি খুব সাধারণ। আপনার কোডটি এর ভিতরে রাখুন:

<androidx.core.widget.NestedScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" 
    android:layout_height="match_parent">

//YOUR CODE

</androidx.core.widget.NestedScrollView>

0

এমনকি উপরে লেখা থাকলেও আপনি যদি স্ক্রোল না পেয়ে থাকেন .....

সেট android:layout_height="250dp"বা আপনি বলতে পারেন xdpযেখানে xকোনো সংখ্যাগত মান হতে পারে।

আমাদের সাইট ব্যবহার করে, আপনি স্বীকার করেছেন যে আপনি আমাদের কুকি নীতি এবং গোপনীয়তা নীতিটি পড়েছেন এবং বুঝতে পেরেছেন ।
Licensed under cc by-sa 3.0 with attribution required.