ScrollView 不显示 LinearLayout 的所有元素

ScrollView not displaying all Elements of LinearLayout

我的 ScrollView 切断了我的 LinearLayout 的一些元素,我检查了边距和所有内容,我不确定为什么会这样。最后一个 cardview 的底部在纵向方向被切断,在横向方向被切断更多。 帮助将不胜感激,谢谢!

<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="wrap_content"
tools:context="com.example.jesse.apbiologystudyappv2.NaturalSelectionActivity$PlaceholderFragment">

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

    <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="8dp"
        card_view:cardElevation="8dp"
        card_view:cardBackgroundColor="@color/cardview_light_background">


        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="8dp"
            android:text="• According to Darwin’s theory of natural selection, competition for limited resources results in differential survival. Individuals with more favorable phenotypes are more likely to survive and produce more offspring, thus passing traits to subsequent generations. It's important to remember that natural selection acts on PHENOTYPES, and individuals with phenotypic advantages will prevail.
• Evolutionary fitness is measured by reproductive success. The most fit individuals have the highest reproductive success.
• Genetic variation and mutation play roles in natural selection. A diverse gene pool is important for the survival of a species in a changing environment.
• Environments can be more or less stable or fluctuating, and this affects evolutionary rate and direction; divergent genetic variations can be selected in each generation.
• An adaptation is a genetic variation that is favored by selection and is manifested as a phenotypic trait that provides an advantage to an organism in a particular environment.
• In addition to natural selection, chance and random events can influence the evolutionary process, ESPECIALLY for small populations.
• Conditions for a population or an allele to be in Hardy-Weinberg equilibrium are: (1) a large population size, (2) absence of migration, (3) no net mutations, (4) random mating and (5) absence of selection. These conditions are seldom met in real populations.
• Mathematical approaches are used to calculate changes in allele frequency, providing evidence for the occurrence of evolution in a population."
            android:textColor="@color/colorPrimaryText"
            android:textSize="16dp"
            android:typeface="sans" />
    </android.support.v7.widget.CardView>

    <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="8dp"
        card_view:cardElevation="8dp"
        card_view:cardBackgroundColor="@color/cardview_light_background">

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

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="8dp"
                android:text="Hardy Weinberg Principle is as follows:"
                android:textColor="@color/colorPrimaryText"
                android:textAlignment="center"
                android:textSize="24dp"
                android:typeface="sans" />

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/hardy_weinberg" />
        </LinearLayout>
    </android.support.v7.widget.CardView>
    <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="8dp"
        card_view:cardElevation="8dp"
        card_view:cardBackgroundColor="@color/cardview_light_background">


        <TextView android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="8dp"
            android:text="• Environments change and act as selective mechanisms on population. For example, Dark Colored moths have risen in population size in industrious cities because smog induced by industry better camouflages dark moths compared to white moths.
• Phenotypic variations are not directed by the environment but occur through random changes in the DNA and through new gene combinations.
• Some phenotypic variations significantly increase or decrease the fitness of the organism and the population. Sickle cell anemia, for example decreases the fitness of humans who are affected.
• Humans impact variation in other species. For example, artificial selection has favored large fruits for consumption.
• Genetic drift is a nonselective process occurring in small populations, in which allele frequencies change as alleles exit and enter the population's gene pool through death, migration, etc.
• Reduction of genetic variation within a given population can increase the differences between populations of the same species.
• Scientific evidence of biological evolution uses information from geographical, geological, physical, chemical and mathematical applications.
• Molecular, morphological and genetic information of existing adn extinct organisms add to our understanding of evolution. For example, the fossil record, relationships within phylogenetic trees, homologous and vestigial structures, the rate of decay of isotopes, etc."
            android:textColor="@color/colorPrimaryText"
            android:textSize="16dp"
            android:typeface="sans" />

    </android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>

将此添加到您的 CardView 元素中:

app:cardUseCompatPadding="true"

在LinearLayout中设置padding

android:padding="5dp"

首先尝试在你的线性布局中添加底部填充,如果它不起作用然后用相对布局替换你的线性布局。

仅从滚动子

中删除 android:layout_gravity="center"

我给 LinearLayout 顶部填充 50dp

 <LinearLayout
            android:id="@+id/linearLayout"
            android:paddingTop="50dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" />