![](/img/trans.png)
[英]Android Scroll View last view not showing inside linear layout
[英]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
來顯示您的數據。
是的,您可以嘗試使用ListView
或GridView
來顯示數據,但RecyclerView
是顯示大數據的最佳選擇。
因為RecycleView
是保存你的 memory。
資源管理器小部件https://developer.android.com/develop/ui/views/layout/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.