簡體   English   中英

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>

僅從滾動子項中刪除 android:layout_gravity="center"

首先嘗試在你的線性布局中添加底部填充,如果它不起作用然后用相對布局替換你的線性布局。

將此添加到您的 CardView 元素:

app:cardUseCompatPadding="true"

在 LinearLayout 中設置 padding

android:padding="5dp"

我給 LinearLayout Top padding 設置了 50dp

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM