[英]Android: Linear layout inside scroll view is not showing more items inside it
**Dear Seniors / Friends ** **亲爱的长辈/朋友们**
I am new in Android development and need your help related to my problem.我是 Android 开发的新手,需要您帮助解决我的问题。 I tried alot to resolve this issue by myself but I am unable to resolve.我尝试了很多自己解决这个问题,但我无法解决。
I am creating an android app in which I have created an activity with scroll view.我正在创建一个 android 应用程序,我在其中创建了一个带有滚动视图的活动。 My main layout is Relative layout.我的主要布局是相对布局。 under Relative layout I user One Linear Layout and in that layout I used Scroll view.`在相对布局下,我使用了一个线性布局,在该布局中,我使用了滚动视图。`
`Under scroll view I created one child linear layout and 17 more linear layouts in the child linear layout. `在滚动视图下,我创建了一个子线性布局和子线性布局中的 17 个线性布局。
My screen is going to disappear when add more Child linear layouts under scrollview-->linear layout.在 scrollview-->linear layout 下添加更多子线性布局时,我的屏幕将消失。
I need to create 120 or more linear layouts in Child Linear layouts of Scroll view.我需要在滚动视图的子线性布局中创建 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>
You must be used RecyclerView
for showing your data.您必须使用RecyclerView
来显示您的数据。
Yes you can try ListView
or GridView
for showing data but RecyclerView
is batter option for showing large data.是的,您可以尝试使用ListView
或GridView
来显示数据,但RecyclerView
是显示大数据的最佳选择。
because RecycleView
is save your memory.因为RecycleView
是保存你的 memory。
Explorer widget https://developer.android.com/develop/ui/views/layout/recyclerview资源管理器小部件https://developer.android.com/develop/ui/views/layout/recyclerview
if you don't wanna use RecyclerView
then use the code.如果您不想使用RecyclerView
,请使用代码。
NestedScrollView
instead of ScrollView
.使用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.