ScrollView改变了小部件android的大小

时间:2016-08-14 20:08:31

标签: android scrollview

大家好,我有这个带滚动视图的xml文件。这在布局编辑器中工作正常,但是当我在android模拟器中运行它时,小部件的大小和缩放变化。我对布局编辑器使用了相同的scrren大小和模拟器。

<?xml version="1.0" encoding="utf-8"?>

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="867dp">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="Arizona State University"
    android:id="@+id/textView41"
    android:layout_alignTop="@+id/view2"
    android:layout_alignParentEnd="true"
    android:layout_toEndOf="@+id/view2"
    android:textSize="18sp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Tution:19,273$"
    android:id="@+id/textView42"
    android:layout_below="@+id/textView41"
    android:layout_marginTop="20sp"
    android:layout_alignStart="@+id/textView41" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:text="Your GPA is 3.5% higher"
    android:id="@+id/textView51"
    android:layout_above="@+id/textView52"
    android:layout_alignParentEnd="true"
    android:layout_alignTop="@+id/imageView5"
    android:layout_toEndOf="@+id/imageView5" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:text="Small Text"
    android:id="@+id/textView52"
    android:layout_below="@+id/view2"
    android:layout_alignParentEnd="true"
    android:layout_above="@+id/textView53"
    android:layout_alignStart="@+id/textView51" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:text="Your GRE verbal is 2.1% higher"
    android:id="@+id/textView53"
    android:layout_marginTop="20dp"
    android:layout_below="@+id/view2"
    android:layout_alignStart="@+id/textView52"
    android:layout_alignEnd="@+id/textView52" />

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageView5"
    android:src="@drawable/tic"
    android:layout_above="@+id/textView52"
    android:layout_centerHorizontal="true" />

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageView6"
    android:layout_alignTop="@+id/textView53"
    android:layout_alignStart="@+id/imageView5"
    android:src="@drawable/tic"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:text="Your GRE Quants is 1.1% higher"
    android:id="@+id/textView47"
    android:layout_below="@+id/textView53"
    android:layout_marginTop="20sp"
    android:layout_alignStart="@+id/textView53"
    android:layout_alignEnd="@+id/textView53" />

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageView4"
    android:layout_alignTop="@+id/textView47"
    android:layout_toStartOf="@+id/textView47"
    android:src="@drawable/tic"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="Specifications"
    android:id="@+id/textView48"
    android:layout_below="@+id/textView47"
    android:layout_marginTop="54dp"
    android:layout_alignStart="@+id/view2"
    android:layout_toStartOf="@+id/textView47" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="https://parttime.com"
    android:id="@+id/textView49"
    android:layout_alignBottom="@+id/imageView7"
    android:layout_alignStart="@+id/textView42"
    android:layout_alignTop="@+id/imageView7"
    android:textSize="21sp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Neural Networks"
    android:id="@+id/textView50"
    android:layout_marginTop="20sp"
    android:layout_below="@+id/textView49"
    android:layout_alignStart="@+id/textView49"
    android:textSize="21sp"/>
/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Databases"
    android:id="@+id/textView54"
    android:layout_marginTop="20sp"
    android:layout_below="@+id/imageView8"
    android:layout_alignStart="@+id/textView50"
    android:textSize="21sp"/>
/>

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageView7"
    android:src="@drawable/bullet_grey"
    android:layout_below="@+id/textView48"
    android:layout_alignStart="@+id/imageView8"
    />

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageView8"
    android:src="@drawable/bullet_grey"
    android:layout_alignTop="@+id/textView50"
    android:layout_toStartOf="@+id/textView54" />

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageView9"
    android:layout_alignTop="@+id/textView54"
    android:layout_alignEnd="@+id/imageView8"
    android:src="@drawable/bullet_grey"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Computer Architecture"
    android:id="@+id/textView55"
    android:layout_below="@+id/textView54"
    android:layout_marginTop="20sp"
    android:layout_alignStart="@+id/textView54"
    android:textSize="21sp"/>
/>

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageView10"
    android:src="@drawable/bullet_grey"
    android:layout_alignTop="@+id/textView55"
    android:layout_toStartOf="@+id/textView55" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Theory"
    android:id="@+id/textView56"
    android:layout_below="@+id/imageView10"
    android:layout_alignStart="@+id/textView55"
    android:layout_marginTop="20sp"
    android:textSize="21sp"/>
/>

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageView11"
    android:layout_alignTop="@+id/textView56"
    android:layout_toStartOf="@+id/textView56"
    android:src="@drawable/bullet_grey"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="Part time jobs"
    android:id="@+id/textView57"
    android:layout_below="@+id/imageView11"
    android:layout_alignEnd="@+id/textView48"
    android:layout_marginTop="41dp"
    android:layout_alignStart="@+id/textView48" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="https://parttime.com"
    android:id="@+id/textView58"
    android:layout_marginTop="39dp"
    android:layout_below="@+id/textView57"
    android:layout_alignStart="@+id/textView56"
    android:layout_alignEnd="@+id/textView55"
    android:textColor="@android:color/darker_gray"/>

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageView12"
    android:layout_alignBottom="@+id/textView58"
    android:layout_alignStart="@+id/imageView11"
    android:layout_toStartOf="@+id/imageView4"
    android:layout_alignEnd="@+id/imageView11"
    android:layout_alignTop="@+id/textView58"
    android:src="@drawable/bullet_grey"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="Admissions"
    android:id="@+id/textView59"
    android:layout_marginTop="47dp"
    android:layout_below="@+id/textView58"
    android:layout_alignStart="@+id/textView57" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="https://parttime.com"
    android:id="@+id/textView60"
    android:textColor="@android:color/darker_gray"
    android:layout_below="@+id/textView59"
    android:layout_alignEnd="@+id/textView49" />

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageView13"
    android:layout_alignStart="@+id/imageView12"
    android:layout_alignTop="@+id/textView60"
    android:layout_alignEnd="@+id/imageView12"
    android:layout_alignBottom="@+id/textView60"
    android:src="@drawable/bullet_grey"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="Research lab links"
    android:id="@+id/textView61"
    android:layout_alignParentBottom="true"
    android:layout_toStartOf="@+id/textView47"
    android:layout_gravity="right" />

</RelativeLayout>
    </LinearLayout>
</ScrollView>

1 个答案:

答案 0 :(得分:0)

滚动视图没有可以继续播放的大小 最好为scrollview

添加LinearLayout父级
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">


<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    android:orientation="vertical">

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

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="867dp"
            android:orientation="vertical">

            <TextView
                android:id="@+id/textView41"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_alignTop="@+id/view2"
                android:layout_toEndOf="@+id/view2"
                android:text="Arizona State University"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textSize="18sp" />

            <TextView
                android:id="@+id/textView42"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignStart="@+id/textView41"
                android:layout_below="@+id/textView41"
                android:layout_marginTop="20sp"
                android:text="Tution:19,273$"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <TextView
                android:id="@+id/textView51"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_above="@+id/textView52"
                android:layout_alignParentEnd="true"
                android:layout_alignTop="@+id/imageView5"
                android:layout_toEndOf="@+id/imageView5"
                android:text="Your GPA is 3.5% higher"
                android:textAppearance="?android:attr/textAppearanceSmall" />

            <TextView
                android:id="@+id/textView52"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_above="@+id/textView53"
                android:layout_alignParentEnd="true"
                android:layout_alignStart="@+id/textView51"
                android:layout_below="@+id/view2"
                android:text="Small Text"
                android:textAppearance="?android:attr/textAppearanceSmall" />

            <TextView
                android:id="@+id/textView53"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignEnd="@+id/textView52"
                android:layout_alignStart="@+id/textView52"
                android:layout_below="@+id/view2"
                android:layout_marginTop="20dp"
                android:text="Your GRE verbal is 2.1% higher"
                android:textAppearance="?android:attr/textAppearanceSmall" />

            <ImageView
                android:id="@+id/imageView5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_above="@+id/textView52"
                android:layout_centerHorizontal="true"
                android:src="@drawable/tic" />

            <ImageView
                android:id="@+id/imageView6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignStart="@+id/imageView5"
                android:layout_alignTop="@+id/textView53"
                android:src="@drawable/tic" />

            <TextView
                android:id="@+id/textView47"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignEnd="@+id/textView53"
                android:layout_alignStart="@+id/textView53"
                android:layout_below="@+id/textView53"
                android:layout_marginTop="20sp"
                android:text="Your GRE Quants is 1.1% higher"
                android:textAppearance="?android:attr/textAppearanceSmall" />

            <ImageView
                android:id="@+id/imageView4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/textView47"
                android:layout_toStartOf="@+id/textView47"
                android:src="@drawable/tic" />

            <TextView
                android:id="@+id/textView48"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignStart="@+id/view2"
                android:layout_below="@+id/textView47"
                android:layout_marginTop="54dp"
                android:layout_toStartOf="@+id/textView47"
                android:text="Specifications"
                android:textAppearance="?android:attr/textAppearanceLarge" />

            <TextView
                android:id="@+id/textView49"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/imageView7"
                android:layout_alignStart="@+id/textView42"
                android:layout_alignTop="@+id/imageView7"
                android:text="https://parttime.com"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="21sp" />

            <TextView
                android:id="@+id/textView50"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignStart="@+id/textView49"
                android:layout_below="@+id/textView49"
                android:layout_marginTop="20sp"
                android:text="Neural Networks"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="21sp" />
            />

            <TextView
                android:id="@+id/textView54"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignStart="@+id/textView50"
                android:layout_below="@+id/imageView8"
                android:layout_marginTop="20sp"
                android:text="Databases"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="21sp" />
            />

            <ImageView
                android:id="@+id/imageView7"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignStart="@+id/imageView8"
                android:layout_below="@+id/textView48"
                android:src="@drawable/bullet_grey" />

            <ImageView
                android:id="@+id/imageView8"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/textView50"
                android:layout_toStartOf="@+id/textView54"
                android:src="@drawable/bullet_grey" />

            <ImageView
                android:id="@+id/imageView9"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignEnd="@+id/imageView8"
                android:layout_alignTop="@+id/textView54"
                android:src="@drawable/bullet_grey" />

            <TextView
                android:id="@+id/textView55"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignStart="@+id/textView54"
                android:layout_below="@+id/textView54"
                android:layout_marginTop="20sp"
                android:text="Computer Architecture"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="21sp" />
            />

            <ImageView
                android:id="@+id/imageView10"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/textView55"
                android:layout_toStartOf="@+id/textView55"
                android:src="@drawable/bullet_grey" />

            <TextView
                android:id="@+id/textView56"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignStart="@+id/textView55"
                android:layout_below="@+id/imageView10"
                android:layout_marginTop="20sp"
                android:text="Theory"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="21sp" />
            />

            <ImageView
                android:id="@+id/imageView11"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/textView56"
                android:layout_toStartOf="@+id/textView56"
                android:src="@drawable/bullet_grey" />

            <TextView
                android:id="@+id/textView57"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignEnd="@+id/textView48"
                android:layout_alignStart="@+id/textView48"
                android:layout_below="@+id/imageView11"
                android:layout_marginTop="41dp"
                android:text="Part time jobs"
                android:textAppearance="?android:attr/textAppearanceLarge" />

            <TextView
                android:id="@+id/textView58"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignEnd="@+id/textView55"
                android:layout_alignStart="@+id/textView56"
                android:layout_below="@+id/textView57"
                android:layout_marginTop="39dp"
                android:text="https://parttime.com"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textColor="@android:color/darker_gray" />

            <ImageView
                android:id="@+id/imageView12"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/textView58"
                android:layout_alignEnd="@+id/imageView11"
                android:layout_alignStart="@+id/imageView11"
                android:layout_alignTop="@+id/textView58"
                android:layout_toStartOf="@+id/imageView4"
                android:src="@drawable/bullet_grey" />

            <TextView
                android:id="@+id/textView59"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignStart="@+id/textView57"
                android:layout_below="@+id/textView58"
                android:layout_marginTop="47dp"
                android:text="Admissions"
                android:textAppearance="?android:attr/textAppearanceLarge" />

            <TextView
                android:id="@+id/textView60"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignEnd="@+id/textView49"
                android:layout_below="@+id/textView59"
                android:text="https://parttime.com"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textColor="@android:color/darker_gray" />

            <ImageView
                android:id="@+id/imageView13"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/textView60"
                android:layout_alignEnd="@+id/imageView12"
                android:layout_alignStart="@+id/imageView12"
                android:layout_alignTop="@+id/textView60"
                android:src="@drawable/bullet_grey" />

            <TextView
                android:id="@+id/textView61"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_gravity="right"
                android:layout_toStartOf="@+id/textView47"
                android:text="Research lab links"
                android:textAppearance="?android:attr/textAppearanceLarge" />

        </RelativeLayout>
    </LinearLayout>
</ScrollView>
</LinearLayout>