Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 将scrollview添加到相对布局会把一切都搞糟_Android_Android Layout - Fatal编程技术网

Android 将scrollview添加到相对布局会把一切都搞糟

Android 将scrollview添加到相对布局会把一切都搞糟,android,android-layout,Android,Android Layout,我是android开发的初学者。我的问题是,每当我将scroll view应用于我的Relativelayout时,一切都乱七八糟。有人能告诉我如何将滚动视图应用到我的应用程序吗?还有一个问题是,当我以纵向模式打开我的应用程序时,当我们将其更改为横向模式时,它将显示应用程序意外停止强制关闭,我想这可能是因为我还没有在应用程序中使用滚动视图,但如果有人有任何问题,请告诉我解决办法请告诉我。这是我的密码: <?xml version="1.0" encoding="utf-8"?>

我是android开发的初学者。我的问题是,每当我将scroll view应用于我的
Relativelayout
时,一切都乱七八糟。有人能告诉我如何将滚动视图应用到我的应用程序吗?还有一个问题是,当我以纵向模式打开我的应用程序时,当我们将其更改为横向模式时,它将显示应用程序意外停止强制关闭,我想这可能是因为我还没有在应用程序中使用滚动视图,但如果有人有任何问题,请告诉我解决办法请告诉我。这是我的密码:

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/ccc"
    android:padding="30dp" >`enter code here`

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

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

            <Button
                android:id="@+id/hundred"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true"
                android:background="@drawable/tenshotrockets_back"
                android:text="      " />

            <Button
                android:id="@+id/ultimate"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:background="@drawable/ultimaterockate_back"
                android:text="      " />

            <Button
                android:id="@+id/power"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:background="@drawable/powerrocket_back"
                android:text="      " />

            <Button
                android:id="@+id/two"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_centerVertical="true"
                android:background="@drawable/twoshots_back"
                android:text="      " />

            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_below="@id/hundred"
                android:text="hundred shots"
                android:textColor="#ffffff" />

            <TextView
                android:id="@+id/textView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_below="@id/two"
                android:text="two shots"
                android:textColor="#ffffff" />

            <TextView
                android:id="@+id/textView8"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBaseline="@id/textView3"
                android:layout_alignBottom="@id/textView3"
                android:layout_alignParentRight="true"
                android:text="ten shots"
                android:textColor="#ffffff" />

            <TextView
                android:id="@+id/textView7"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/power"
                android:layout_below="@+id/power"
                android:text="power rocket"
                android:textColor="#ffffff" />

            <TextView
                android:id="@+id/textView4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBaseline="@+id/textView2"
                android:layout_alignBottom="@+id/textView2"
                android:layout_centerHorizontal="true"
                android:text="ultimate rocket"
                android:textColor="#ffffff" />

            <Button
                android:id="@+id/ten"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBaseline="@+id/music_blast"
                android:layout_alignBottom="@+id/music_blast"
                android:layout_alignLeft="@+id/textView8"
                android:background="@drawable/threeshots_back"
                android:text="      " />

            <TextView
                android:id="@+id/textView5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBaseline="@+id/textView8"
                android:layout_alignBottom="@+id/textView8"
                android:layout_alignLeft="@+id/ultimate"
                android:text="musical blast"
                android:textColor="#ffffff" />

            <Button
                android:id="@+id/music_blast"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_above="@+id/textView5"
                android:layout_alignLeft="@+id/textView5"
                android:background="@drawable/musical_blast"
                android:text="      " />

            <Button
                android:id="@+id/music_rocket"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBaseline="@+id/Bottle_rock"
                android:layout_alignBottom="@+id/Bottle_rock"
                android:layout_alignRight="@+id/textView3"
                android:background="@drawable/musicalrocket_back"
                android:text="      " />

            <TextView
                android:id="@+id/textView9"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/music_rocket"
                android:layout_alignParentBottom="true"
                android:text="musical"
                android:textColor="#ffffff" />

            <TextView
                android:id="@+id/textView6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/Bottle_rock"
                android:layout_alignParentBottom="true"
                android:text="bottle rocket"
                android:textColor="#ffffff" />

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignRight="@+id/music_bank"
                android:text="sound"
                android:textColor="#ffffff" />

            <Button
                android:id="@+id/Bottle_rock"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_above="@+id/textView6"
                android:layout_alignLeft="@+id/textView5"
                android:background="@drawable/musicalsimple_back"
                android:text="      " />

            <Button
                android:id="@+id/music_bank"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBaseline="@+id/Bottle_rock"
                android:layout_alignBottom="@+id/Bottle_rock"
                android:layout_alignLeft="@+id/textView8"
                android:background="@drawable/musicalsmall"
                android:text="      " />
        </RelativeLayout>
    </ScrollView>

</RelativeLayout>

`在这里输入代码`

在滚动视图中需要fillViewportXML属性

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="30dp" >

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true" > <!-- add this attribute -->

        <RelativeLayout ...

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


在滚动视图中需要fillViewportXML属性

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="30dp" >

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true" > <!-- add this attribute -->

        <RelativeLayout ...

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


先生,我如何防止我的应用程序崩溃?先生,我已经在scrollview中实现了这一点,但当我访问移动应用程序时,其中没有滚动视图…先生,我如何防止我的应用程序崩溃?先生,我已经在scrollview中实现了这一点,但当我访问移动应用程序时,其中没有滚动视图。。。。