java - Implementing ScrollView Causes Fatal Exception -
i have relativelayout i'm attempting add ability scroll down on - when device in horizontal position. (currently - button disappears when flip horizontally - undesired.)
current xml state:
<?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/background" android:orientation="vertical" > <button android:id="@+id/go_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/text" android:layout_centerhorizontal="true" android:layout_margintop="85dp" android:background="@drawable/apn_app_go_button" /> <imageview android:id="@+id/emblem" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparenttop="true" android:layout_centerhorizontal="true" android:layout_margintop="20dp" android:gravity="center" android:scaletype="fitstart" android:src="@drawable/apn_app_logo" /> <textview android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/emblem" android:layout_centerhorizontal="true" android:gravity="center" android:text="@string/start_text" android:textcolor="#000000" android:textsize="14sp" /> </relativelayout>
the problem when attempt change xml above scrollview:
<?xml version="1.0" encoding="utf-8"?> <scrollview xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/background" android:orientation="vertical" > <button android:id="@+id/go_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/text" android:layout_centerhorizontal="true" android:layout_margintop="85dp" android:background="@drawable/apn_app_go_button" /> <imageview android:id="@+id/emblem" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparenttop="true" android:layout_centerhorizontal="true" android:layout_margintop="20dp" android:gravity="center" android:scaletype="fitstart" android:src="@drawable/apn_app_logo" /> <textview android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/emblem" android:layout_centerhorizontal="true" android:gravity="center" android:text="@string/start_text" android:textcolor="#000000" android:textsize="14sp" /> </scrollview>
i fatal exception:
08-23 11:06:52.419: e/androidruntime(3919): fatal exception: main 08-23 11:06:52.419: e/androidruntime(3919): java.lang.runtimeexception: unable start activity componentinfo{com.project.new.datasettings/com.project.new.datasettings.startactivity}: java.lang.illegalstateexception: scrollview can host 1 direct child 08-23 11:06:52.419: e/androidruntime(3919): @ android.app.activitythread.performlaunchactivity(activitythread.java:1960) 08-23 11:06:52.419: e/androidruntime(3919): @ android.app.activitythread.handlelaunchactivity(activitythread.java:1985) 08-23 11:06:52.419: e/androidruntime(3919): @ android.app.activitythread.access$600(activitythread.java:123) 08-23 11:06:52.419: e/androidruntime(3919): @ android.app.activitythread$h.handlemessage(activitythread.java:1151) 08-23 11:06:52.419: e/androidruntime(3919): @ android.os.handler.dispatchmessage(handler.java:99) 08-23 11:06:52.419: e/androidruntime(3919): @ android.os.looper.loop(looper.java:137) 08-23 11:06:52.419: e/androidruntime(3919): @ android.app.activitythread.main(activitythread.java:4429) 08-23 11:06:52.419: e/androidruntime(3919): @ java.lang.reflect.method.invokenative(native method) 08-23 11:06:52.419: e/androidruntime(3919): @ java.lang.reflect.method.invoke(method.java:511) 08-23 11:06:52.419: e/androidruntime(3919): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:791) 08-23 11:06:52.419: e/androidruntime(3919): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:558) 08-23 11:06:52.419: e/androidruntime(3919): @ dalvik.system.nativestart.main(native method) 08-23 11:06:52.419: e/androidruntime(3919): caused by: java.lang.illegalstateexception: scrollview can host 1 direct child 08-23 11:06:52.419: e/androidruntime(3919): @ android.widget.scrollview.addview(scrollview.java:241) 08-23 11:06:52.419: e/androidruntime(3919): @ android.view.layoutinflater.rinflate(layoutinflater.java:743) 08-23 11:06:52.419: e/androidruntime(3919): @ android.view.layoutinflater.inflate(layoutinflater.java:489) 08-23 11:06:52.419: e/androidruntime(3919): @ android.view.layoutinflater.inflate(layoutinflater.java:396) 08-23 11:06:52.419: e/androidruntime(3919): @ android.view.layoutinflater.inflate(layoutinflater.java:352) 08-23 11:06:52.419: e/androidruntime(3919): @ com.android.internal.policy.impl.phonewindow.setcontentview(phonewindow.java:252) 08-23 11:06:52.419: e/androidruntime(3919): @ android.app.activity.setcontentview(activity.java:1841) 08-23 11:06:52.419: e/androidruntime(3919): @ com.project.new.datasettings.startactivity.oncreate(startactivity.java:44) 08-23 11:06:52.419: e/androidruntime(3919): @ android.app.activity.performcreate(activity.java:4471) 08-23 11:06:52.419: e/androidruntime(3919): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1049) 08-23 11:06:52.419: e/androidruntime(3919): @ android.app.activitythread.performlaunchactivity(activitythread.java:1924) 08-23 11:06:52.419: e/androidruntime(3919): ... 11 more
a scrollview
can have 1 child element. have 3, button, imageview, , textview. try wrapping relativelayout
scrollview
:
<?xml version="1.0" encoding="utf-8"?> <scrollview xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/background" android:orientation="vertical" > <relativelayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/background" android:orientation="vertical" > <button android:id="@+id/go_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/text" android:layout_centerhorizontal="true" android:layout_margintop="85dp" android:background="@drawable/apn_app_go_button" /> <imageview android:id="@+id/emblem" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparenttop="true" android:layout_centerhorizontal="true" android:layout_margintop="20dp" android:gravity="center" android:scaletype="fitstart" android:src="@drawable/apn_app_logo" /> <textview android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/emblem" android:layout_centerhorizontal="true" android:gravity="center" android:text="@string/start_text" android:textcolor="#000000" android:textsize="14sp" /> </relativelayout> </scrollview>
Comments
Post a Comment