滚动视图未显示LinearLayout的所有元素



我的ScrollView正在剪切LinearLayout的一些元素,我检查了页边空白和所有内容,我不确定为什么会发生这种情况。最后一张卡片视图的底部在纵向方向上被切掉,在横向方向上被剪掉的更多。我们将不胜感激,谢谢!

<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>

仅从滚动子中删除android:layout_gravity="center"

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

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

app:cardUseCompatPadding="true"

在LinearLayout 中设置填充

android:padding="5dp"

我给了我的LinearLayout顶部填充50dp

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

最新更新