繁体   English   中英

Android:滚动视图内的线性布局未在其中显示更多项目

[英]Android: Linear layout inside scroll view is not showing more items inside it

**亲爱的长辈/朋友们**

我是 Android 开发的新手,需要您帮助解决我的问题。 我尝试了很多自己解决这个问题,但我无法解决。

我正在创建一个 android 应用程序,我在其中创建了一个带有滚动视图的活动。 我的主要布局是相对布局。 在相对布局下,我使用了一个线性布局,在该布局中,我使用了滚动视图。`

`在滚动视图下,我创建了一个子线性布局和子线性布局中的 17 个线性布局。

在 scrollview-->linear layout 下添加更多子线性布局时,我的屏幕将消失。

我需要在滚动视图的子线性布局中创建 120 个或更多线性布局。

`

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/Newbackgroundclr" android:orientation="vertical" android:alpha=".9" tools:context=".AlquranActivity"> <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/Quranbackground"
    android:orientation="vertical"
    android:alpha=".9"
    android:gravity="center">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:layout_marginBottom="15dp"
    android:orientation="horizontal"
    tools:ignore="UseCompoundDrawables">
    <ImageView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_gravity="center_vertical"
        android:contentDescription="@string/content_quran_image"
        app:srcCompat="@drawable/qurankareem" />
    <TextView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:fontFamily="cursive"
        android:gravity="center_vertical"
        android:text="Quran al Kareem"
        android:textAllCaps="false"
        android:textColor="@color/white"
        android:textSize="40sp"
        android:textStyle="bold" />
</LinearLayout>
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <!--All Sorahs Layouts starts here..... -->
        <!-- Surat al Fatiha upto Sorat al Naas -->

        <!--Fatiha -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="65dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/customeborder"
            android:orientation="horizontal">

            <ImageView
                android:layout_width="100dp"
                android:layout_height="match_parent"
                android:layout_marginRight="4dp"
                android:background="@drawable/customeborder"
                android:padding="14dp"
                android:tint="@color/white"
                app:srcCompat="@drawable/alfatiha" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/customeborder"
                android:orientation="vertical">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Surat-ul-Fatiha"
                    android:textColor="@color/white"
                    android:textSize="20sp"
                    android:textStyle="bold" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Verses #7 , Rukus #1"
                    android:textColor="@color/white"
                    android:textSize="13sp"
                    android:textStyle="bold" />
            </LinearLayout>
        </LinearLayout>
        <!--Baqara -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="65dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/customeborder"
            android:orientation="horizontal">

            <ImageView
                android:layout_width="100dp"
                android:layout_height="match_parent"
                android:layout_marginRight="4dp"
                android:background="@drawable/customeborder"
                android:padding="6dp"
                android:tint="@color/white"
                app:srcCompat="@drawable/albaqarah" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/customeborder"
                android:orientation="vertical">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Surat-ul-Baqara"
                    android:textColor="@color/white"
                    android:textSize="20sp"
                    android:textStyle="bold" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Verses #286 , Rukus #40"
                    android:textColor="@color/white"
                    android:textSize="12sp"
                    android:textStyle="bold" />
            </LinearLayout>
        </LinearLayout>
        <!-- Aal -e- Imran -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="65dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/customeborder"
            android:orientation="horizontal">

            <ImageView
                android:layout_width="100dp"
                android:layout_height="match_parent"
                android:layout_marginRight="4dp"
                android:background="@drawable/customeborder"
                android:padding="6dp"
                android:tint="@color/white"
                app:srcCompat="@drawable/alimran" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/customeborder"
                android:orientation="vertical">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Surah Aal e Imran"
                    android:textColor="@color/white"
                    android:textSize="20sp"
                    android:textStyle="bold" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Verses #200 , Rukus #20"
                    android:textColor="@color/white"
                    android:textSize="12sp"
                    android:textStyle="bold" />
            </LinearLayout>
        </LinearLayout>
        <!-- Nisa -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="65dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/customeborder"
            android:orientation="horizontal">

            <ImageView
                android:layout_width="100dp"
                android:layout_height="match_parent"
                android:layout_marginRight="4dp"
                android:background="@drawable/customeborder"
                android:padding="4dp"
                android:tint="@color/white"
                app:srcCompat="@drawable/annisa" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/customeborder"
                android:orientation="vertical">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Surah An-Nisa"
                    android:textColor="@color/white"
                    android:textSize="20sp"
                    android:textStyle="bold" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Verses #176 , Rukus #24"
                    android:textColor="@color/white"
                    android:textSize="12sp"
                    android:textStyle="bold" />
            </LinearLayout>
        </LinearLayout>
        <!-- Maidah -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="65dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/customeborder"
            android:orientation="horizontal">

            <ImageView
                android:layout_width="100dp"
                android:layout_height="match_parent"
                android:layout_marginRight="4dp"
                android:background="@drawable/customeborder"
                android:padding="6dp"
                android:tint="@color/white"
                app:srcCompat="@drawable/almaidah" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/customeborder"
                android:orientation="vertical">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Sorah Al-Ma’idah"
                    android:textColor="@color/white"
                    android:textSize="20sp"
                    android:textStyle="bold" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Verses #120 , Rukus #16"
                    android:textColor="@color/white"
                    android:textSize="12sp"
                    android:textStyle="bold" />
            </LinearLayout>
        </LinearLayout>
        <!-- An am -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="65dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/customeborder"
            android:orientation="horizontal">

            <ImageView
                android:layout_width="100dp"
                android:layout_height="match_parent"
                android:layout_marginRight="4dp"
                android:background="@drawable/customeborder"
                android:padding="5dp"
                android:tint="@color/white"
                app:srcCompat="@drawable/alanam" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/customeborder"
                android:orientation="vertical">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Sorah Al-An’am"
                    android:textColor="@color/white"
                    android:textSize="20sp"
                    android:textStyle="bold" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Verses #165 , Rukus #20"
                    android:textColor="@color/white"
                    android:textSize="12sp"
                    android:textStyle="bold" />
            </LinearLayout>
        </LinearLayout>
        <!-- Al'araf -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="65dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/customeborder"
            android:orientation="horizontal">

            <ImageView
                android:layout_width="100dp"
                android:layout_height="match_parent"
                android:layout_marginRight="4dp"
                android:background="@drawable/customeborder"
                android:padding="5dp"
                android:tint="@color/white"
                app:srcCompat="@drawable/alaraf" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/customeborder"
                android:orientation="vertical">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Sorah Al-A’raf"
                    android:textColor="@color/white"
                    android:textSize="20sp"
                    android:textStyle="bold" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Verses #206 , Rukus #24"
                    android:textColor="@color/white"
                    android:textSize="12sp"
                    android:textStyle="bold" />
            </LinearLayout>
        </LinearLayout>
        <!-- anfaal -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="65dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/customeborder"
            android:orientation="horizontal">

            <ImageView
                android:layout_width="100dp"
                android:layout_height="match_parent"
                android:layout_marginRight="4dp"
                android:background="@drawable/customeborder"
                android:padding="8dp"
                android:tint="@color/white"
                app:srcCompat="@drawable/anfaal" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/customeborder"
                android:orientation="vertical">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Sorah Al-Anfal"
                    android:textColor="@color/white"
                    android:textSize="20sp"
                    android:textStyle="bold" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Verses #75 , Rukus #10"
                    android:textColor="@color/white"
                    android:textSize="12sp"
                    android:textStyle="bold" />
            </LinearLayout>

        </LinearLayout>
        <!-- Taubah -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="65dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/customeborder"
            android:orientation="horizontal">

            <ImageView
                android:layout_width="100dp"
                android:layout_height="match_parent"
                android:layout_marginRight="4dp"
                android:background="@drawable/customeborder"
                android:padding="7dp"
                android:tint="@color/white"
                app:srcCompat="@drawable/taubah" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/customeborder"
                android:orientation="vertical">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Sorah At-Taubah"
                    android:textColor="@color/white"
                    android:textSize="20sp"
                    android:textStyle="bold" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Verses #129 , Rukus #16"
                    android:textColor="@color/white"
                    android:textSize="12sp"
                    android:textStyle="bold" />
            </LinearLayout>

        </LinearLayout>
        <!-- Younus -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="65dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/customeborder"
            android:orientation="horizontal">

            <ImageView
                android:layout_width="100dp"
                android:layout_height="match_parent"
                android:layout_marginRight="4dp"
                android:background="@drawable/customeborder"
                android:padding="4dp"
                android:tint="@color/white"
                app:srcCompat="@drawable/younus" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/customeborder"
                android:orientation="vertical">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Surah Younas"
                    android:textColor="@color/white"
                    android:textSize="20sp"
                    android:textStyle="bold" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Verses #109 , Rukus #11"
                    android:textColor="@color/white"
                    android:textSize="12sp"
                    android:textStyle="bold" />
            </LinearLayout>

        </LinearLayout>
        <!-- Hud -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="65dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/customeborder"
            android:orientation="horizontal">

            <ImageView
                android:layout_width="100dp"
                android:layout_height="match_parent"
                android:layout_marginRight="4dp"
                android:background="@drawable/customeborder"
                android:padding="6dp"
                android:tint="@color/white"
                app:srcCompat="@drawable/hud" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/customeborder"
                android:orientation="vertical">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Surah Hud"
                    android:textColor="@color/white"
                    android:textSize="20sp"
                    android:textStyle="bold" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Verses #123 , Rukus #10"
                    android:textColor="@color/white"
                    android:textSize="12sp"
                    android:textStyle="bold" />
            </LinearLayout>

        </LinearLayout>
        <!-- Yousuf -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="65dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/customeborder"
            android:orientation="horizontal">

            <ImageView
                android:layout_width="100dp"
                android:layout_height="match_parent"
                android:layout_marginRight="4dp"
                android:background="@drawable/customeborder"
                android:padding="6dp"
                android:tint="@color/white"
                app:srcCompat="@drawable/yousuf" />
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/customeborder"
                android:orientation="vertical">
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Surah Yousaf"
                    android:textColor="@color/white"
                    android:textSize="20sp"
                    android:textStyle="bold" />
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Verses #111 , Rukus #12"
                    android:textColor="@color/white"
                    android:textSize="12sp"
                    android:textStyle="bold" />
            </LinearLayout>
        </LinearLayout>
        <!-- Ar'Rad-->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="65dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/customeborder"
            android:orientation="horizontal">

            <ImageView
                android:layout_width="100dp"
                android:layout_height="match_parent"
                android:layout_marginRight="4dp"
                android:background="@drawable/customeborder"
                android:padding="6dp"
                android:tint="@color/white"
                app:srcCompat="@drawable/arraad" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/customeborder"
                android:orientation="vertical">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Surah Ar-Ra’d"
                    android:textColor="@color/white"
                    android:textSize="20sp"
                    android:textStyle="bold" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Verses #43 , Rukus #6"
                    android:textColor="@color/white"
                    android:textSize="12sp"
                    android:textStyle="bold" />
            </LinearLayout>

        </LinearLayout>
        
    </LinearLayout>
</ScrollView> 

您必须使用RecyclerView来显示您的数据。

如果您不想使用RecyclerView ,请使用代码。

  • 使用NestedScrollView而不是ScrollView
    <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">

        <androidx.core.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

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


            </LinearLayout>
        </androidx.core.widget.NestedScrollView>
    </RelativeLayout>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM