আমি কীভাবে লিনিয়ারআলআউটকে স্ক্রোলযোগ্য করব?


155

আমি ক্রিয়াকলাপটি শুরু করার পরে নীচে সংজ্ঞায়িত এক্সএমএলে অন্যান্য বোতাম এবং বিকল্পগুলি দেখতে আমি নীচে স্ক্রোল করতে পারছি না।

কেউ কীভাবে এই স্ক্রোলযোগ্য করতে জানে?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_height="wrap_content"
 android:layout_width="fill_parent"
 android:background="#000044"
 android:isScrollContainer="true"
 android:orientation="vertical">
 <TextView
  android:id="@+id/title"
  android:text="@string/title"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:textColor="#ffffff"/>
 <EditText
  android:id="@+id/editTitle"
  android:text=""
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"/>
 <TextView
  android:id="@+id/description"
  android:text="@string/description"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:textColor="#ffffff"/>
 <EditText
  android:id="@+id/editDescription"
  android:text=""
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"/>
 <TextView
  android:id="@+id/location"
  android:text="@string/location"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:textColor="#ffffff"/>
 <EditText
  android:id="@+id/editLocation"
  android:text=""
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"/>
 <TextView
  android:id="@+id/startTime"
  android:text="@string/startTime"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:textColor="#ffffff"/>
 <DatePicker 
  android:id="@+id/DatePicker01" 
  android:layout_width="wrap_content" 
  android:layout_height="wrap_content" />
 <TimePicker 
  android:id="@+id/TimePicker01" 
  android:layout_width="wrap_content" 
  android:layout_height="wrap_content"/>
 <TextView
  android:id="@+id/endTime"
  android:text="@string/endTime"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:textColor="#ffffff"/>
 <DatePicker 
  android:id="@+id/DatePicker02" 
  android:layout_width="wrap_content" 
  android:layout_height="wrap_content" />
 <TimePicker 
  android:id="@+id/TimePicker02" 
  android:layout_width="wrap_content" 
  android:layout_height="wrap_content"/>
 <Button
  android:id="@+id/buttonCreate"
  android:text="Create"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"/>
</LinearLayout>

আমার ক্লাস কোডটি

package com.example.blah;

import android.app.Activity;
import android.os.Bundle;

public class example extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}

উত্তর:


229

7
এটি পার্শ্ব প্রতিক্রিয়া, যেমন কোনও স্ক্রোলভিউয়ের মধ্যে কোনও তালিকা দর্শনের মতো স্ক্রোলযোগ্য উপাদান স্থাপন করতে সক্ষম না হওয়া।
জোয়াওফিলিপক্লেমেটমার্টিনস

4
স্ক্রোলযোগ্য সামগ্রীর ভিতরে আপনার স্ক্রোলযোগ্য সামগ্রী এড়ানো উচিত। ব্যবহারকারীরা এটি পছন্দ করবে না (আপনি কখনই জানেন না যে আপনি কোন স্ক্রোলটি সরান)।
গিলিয়াম

@ জোয়াওফিলিপক্লেমেটমার্টিনস যদি আপনি তালিকাভিউয়ের অ্যাডাপ্টারের কার্যকারিতা থেকে উপকার না নিয়ে থাকেন তবে আপনি অন্যান্য তালিকার সাথে স্ক্রোলযোগ্য বাক্সে সমস্ত প্রবাহিত বোধ করার জন্য কেবল নিজের তালিকার সমস্ত উপাদানকে লিনিয়ারলআউট র‌্যাপারে যুক্ত করতে পারেন।
অথর্ব

এটি একটি ভাল স্ক্রোলযোগ্য বিন্যাস তৈরি করবে না, বিশেষত যদি আপনার ট্যাব থাকে এবং তাদের মধ্যে স্থানান্তর করতে চান। এটি সঠিকভাবে স্থানান্তরিত হবে না এবং আপনি স্ক্রোল করার সময় এটি পাশের একটি বারও দেখায়
সর্বদা কনফিউজড

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

    <LinearLayout ...>

        ...
        ...

    </LinearLayout>

</ScrollView>

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

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

        Your views go here...

    </LinearLayout>

</ScrollView>

17

আপনার সম্পূর্ণ সামগ্রীটি রৈখিক বিন্যাসে রাখুন যা ভিতরে স্থাপন করা হয় ScrollView

ScrollView এটির সন্তানের হিসাবে একটি মাত্র বিন্যাস গ্রহণ করে।

isScrollContainer="true"

যখন অ্যান্ড্রয়েডে আপনার সফটকি পপ আপ হয় এবং তখনও আপনি নিজের ভিউ স্ক্রোল করতে চান তখন এই সম্পত্তিটি ব্যবহৃত হয়।


3

আপনি View.scrolTo (..) ব্যবহার করেও এটি প্রয়োগ করতে পারেন ।

postDelayed(new Runnable() {
            public void run() {

                counter = (int) (counter + 10);
                handler.postDelayed(this, 100);

                    llParent.scrollTo(counter , 0);
                }

            }
        }, 1000L);

2

আপনি যে কোনও লেআউটকে স্ক্রোলযোগ্য করতে পারেন। কেবল <?xml version="1.0" encoding="utf-8"?>এই লাইনগুলিকে যুক্ত করুন:

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

এবং শেষে অ্যাড </ScrollView>

অ-স্ক্রোলযোগ্য ক্রিয়াকলাপের উদাহরণ:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    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:verticalScrollbarPosition="right"
    tools:context="p32929.demo.MainActivity">


    <TextView
        android:text="TextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="102dp"
        android:id="@+id/textView"
        android:textSize="30sp" />
</RelativeLayout>

এটিকে স্ক্রোলযোগ্য করার পরে এটি এর মতো হয়ে যায়:

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

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

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/activity_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        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:verticalScrollbarPosition="right"
        tools:context="p32929.demo.MainActivity">


        <TextView
            android:id="@+id/textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="102dp"
            android:text="TextView"
            android:textSize="30sp" />
    </RelativeLayout>
</ScrollView>

1

আপনার সমস্ত বিন্যাস প্রস্থ এবং উচ্চতা সহ পূর্ণ স্ক্রোলভিউতে পূরণ করুন_পরেণ্য সেট করুন।


আপনার উত্তরটি উত্তরের পরিবর্তে কোনও মন্তব্যের মতো দেখাচ্ছে। আপনার যথেষ্ট খ্যাতি অর্জনের পরে আপনি কোনও পোস্টে মন্তব্য করতে সক্ষম হবেন । পরিবর্তে আমি কি করতে পারি তা এটি পরীক্ষা করে দেখুন । যদি আপনি কোনও উত্তর দেওয়ার ইচ্ছা করেন তবে একটি মানের উত্তর দেওয়ার জন্য এই -কীভাবে উত্তরটি পড়ুন।
ওয়েওওয়েওয়ের

ভরা_পিতা ইতিমধ্যে অবচয় এবং ম্যাচ পিতা
অসীম লুপগুলি

0

কোড নীচে এটি চেষ্টা করুন

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/constraintLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    tools:context="com.example.blah"
    >

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

        <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:background="#000044"
            android:orientation="vertical">
            <TextView
                android:id="@+id/title"
                android:text="@string/title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="#ffffff"/>
            <EditText
                android:id="@+id/editTitle"
                android:text=""
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"/>
            <TextView
                android:id="@+id/description"
                android:text="@string/description"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="#ffffff"/>
            <EditText
                android:id="@+id/editDescription"
                android:text=""
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"/>
            <TextView
                android:id="@+id/location"
                android:text="@string/location"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="#ffffff"/>
            <EditText
                android:id="@+id/editLocation"
                android:text=""
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"/>
            <TextView
                android:id="@+id/startTime"
                android:text="@string/startTime"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="#ffffff"/>
            <DatePicker
                android:id="@+id/DatePicker01"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
            <TimePicker
                android:id="@+id/TimePicker01"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>
            <TextView
                android:id="@+id/endTime"
                android:text="@string/endTime"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="#ffffff"/>
            <DatePicker
                android:id="@+id/DatePicker02"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
            <TimePicker
                android:id="@+id/TimePicker02"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>
            <Button
                android:id="@+id/buttonCreate"
                android:text="Create"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>
        </LinearLayout></ScrollView></RelativeLayout>
আমাদের সাইট ব্যবহার করে, আপনি স্বীকার করেছেন যে আপনি আমাদের কুকি নীতি এবং গোপনীয়তা নীতিটি পড়েছেন এবং বুঝতে পেরেছেন ।
Licensed under cc by-sa 3.0 with attribution required.