android - Scrolling page with image/text/image -
i'm newbie working on first ever app. want have page images @ top , bottom , large block of text in between. want scroll vertically. no matter try emulator stops app when access page.
<?xml version="1.0" encoding="utf-8"?> <scrollview xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <relativelayout android:layout_width="fill_parent" android:layout_height="fill_parent"> <tablelayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:stretchcolumns="1"> <tablerow> <imageview android:layout_margin="6dip" android:id="@+id/francis_top" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:src="@drawable/fhpaint"> </imageview> </tablerow> <tablerow> <textview android:id="@+id/help_page_intro" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textcolor="#ffffff" android:background="#2e2d2b" android:textsize="18sp" android:text="@string/francisinfo" android:padding="2dip"> </textview> </tablerow> <tablerow> <imageview android:layout_margin="6dip" android:id="@+id/francis_bottom" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:src="@drawable/fhp"> </imageview> </tablerow> </tablelayout> </relativelayout> </scrollview>
any appreciated.
kind regards, ian
edit: errors in log:
02-05 18:44:24.391: i/process(836): sending signal. pid: 836 sig: 9 02-05 18:44:32.041: d/gralloc_goldfish(1098): emulator without gpu emulation detected. 02-05 18:44:32.151: d/dalvikvm(1098): gc_for_alloc freed 42k, 4% free 3213k/3332k, paused 45ms, total 49ms 02-05 18:44:32.201: d/dalvikvm(1098): gc_for_alloc freed 6k, 4% free 3572k/3692k, paused 36ms, total 36ms 02-05 18:44:32.321: i/choreographer(1098): skipped 61 frames! application may doing work on main thread. 02-05 18:44:37.911: d/dalvikvm(1098): gc_for_alloc freed 483k, 16% free 3234k/3812k, paused 106ms, total 121ms 02-05 18:44:37.971: i/dalvikvm-heap(1098): grow heap (frag case) 4.503mb 1334776-byte allocation 02-05 18:44:38.311: d/dalvikvm(1098): gc_for_alloc freed 11k, 12% free 4526k/5116k, paused 88ms, total 89ms 02-05 18:44:38.471: d/dalvikvm(1098): gc_for_alloc freed <1k, 11% free 4585k/5116k, paused 114ms, total 116ms 02-05 18:44:38.471: i/dalvikvm-heap(1098): grow heap (frag case) 5.157mb 635812-byte allocation 02-05 18:44:38.781: d/dalvikvm(1098): gc_for_alloc freed <1k, 10% free 5206k/5740k, paused 83ms, total 84ms 02-05 18:44:39.461: i/choreographer(1098): skipped 112 frames! application may doing work on main thread. 02-05 18:44:40.741: i/choreographer(1098): skipped 108 frames! application may doing work on main thread. 02-05 18:44:41.151: i/choreographer(1098): skipped 34 frames! application may doing work on main thread. 02-05 18:44:45.811: d/androidruntime(1098): shutting down vm 02-05 18:44:45.811: w/dalvikvm(1098): threadid=1: thread exiting uncaught exception (group=0xb3a4fba8) 02-05 18:44:45.981: e/androidruntime(1098): fatal exception: main 02-05 18:44:45.981: e/androidruntime(1098): process: com.androidbook.ds1, pid: 1098 02-05 18:44:45.981: e/androidruntime(1098): java.lang.runtimeexception: unable start activity componentinfo{com.androidbook.ds1/com.androidbook.ds1.quizfrancisactivity}: android.view.inflateexception: binary xml file line #3: error inflating class scrollview 02-05 18:44:45.981: e/androidruntime(1098): @ android.app.activitythread.performlaunchactivity(activitythread.java:2195) 02-05 18:44:45.981: e/androidruntime(1098): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2245) 02-05 18:44:45.981: e/androidruntime(1098): @ android.app.activitythread.access$800(activitythread.java:135) 02-05 18:44:45.981: e/androidruntime(1098): @ android.app.activitythread$h.handlemessage(activitythread.java:1196) 02-05 18:44:45.981: e/androidruntime(1098): @ android.os.handler.dispatchmessage(handler.java:102) 02-05 18:44:45.981: e/androidruntime(1098): @ android.os.looper.loop(looper.java:136) 02-05 18:44:45.981: e/androidruntime(1098): @ android.app.activitythread.main(activitythread.java:5017) 02-05 18:44:45.981: e/androidruntime(1098): @ java.lang.reflect.method.invokenative(native method) 02-05 18:44:45.981: e/androidruntime(1098): @ java.lang.reflect.method.invoke(method.java:515) 02-05 18:44:45.981: e/androidruntime(1098): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779) 02-05 18:44:45.981: e/androidruntime(1098): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:595) 02-05 18:44:45.981: e/androidruntime(1098): @ dalvik.system.nativestart.main(native method) 02-05 18:44:45.981: e/androidruntime(1098): caused by: android.view.inflateexception: binary xml file line #3: error inflating class scrollview 02-05 18:44:45.981: e/androidruntime(1098): @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:707) 02-05 18:44:45.981: e/androidruntime(1098): @ android.view.layoutinflater.inflate(layoutinflater.java:469) 02-05 18:44:45.981: e/androidruntime(1098): @ android.view.layoutinflater.inflate(layoutinflater.java:397) 02-05 18:44:45.981: e/androidruntime(1098): @ android.view.layoutinflater.inflate(layoutinflater.java:353) 02-05 18:44:45.981: e/androidruntime(1098): @ com.android.internal.policy.impl.phonewindow.setcontentview(phonewindow.java:290) 02-05 18:44:45.981: e/androidruntime(1098): @ android.app.activity.setcontentview(activity.java:1929) 02-05 18:44:45.981: e/androidruntime(1098): @ com.androidbook.ds1.quizfrancisactivity.oncreate(quizfrancisactivity.java:10) 02-05 18:44:45.981: e/androidruntime(1098): @ android.app.activity.performcreate(activity.java:5231) 02-05 18:44:45.981: e/androidruntime(1098): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1087) 02-05 18:44:45.981: e/androidruntime(1098): @ android.app.activitythread.performlaunchactivity(activitythread.java:2159) 02-05 18:44:45.981: e/androidruntime(1098): ... 11 more 02-05 18:44:45.981: e/androidruntime(1098): caused by: java.lang.classnotfoundexception: didn't find class "android.view.scrollview" on path: dexpathlist[[zip file "/data/app/com.androidbook.ds1-2.apk"],nativelibrarydirectories=[/data/app-lib/com.androidbook.ds1-2, /system/lib]] 02-05 18:44:45.981: e/androidruntime(1098): @ dalvik.system.basedexclassloader.findclass(basedexclassloader.java:56) 02-05 18:44:45.981: e/androidruntime(1098): @ java.lang.classloader.loadclass(classloader.java:497) 02-05 18:44:45.981: e/androidruntime(1098): @ java.lang.classloader.loadclass(classloader.java:457) 02-05 18:44:45.981: e/androidruntime(1098): @ android.view.layoutinflater.createview(layoutinflater.java:559) 02-05 18:44:45.981: e/androidruntime(1098): @ android.view.layoutinflater.oncreateview(layoutinflater.java:652) 02-05 18:44:45.981: e/androidruntime(1098): @ com.android.internal.policy.impl.phonelayoutinflater.oncreateview(phonelayoutinflater.java:66) 02-05 18:44:45.981: e/androidruntime(1098): @ android.view.layoutinflater.oncreateview(layoutinflater.java:669) 02-05 18:44:45.981: e/androidruntime(1098): @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:694) 02-05 18:44:45.981: e/androidruntime(1098): ... 20 more
thank responding quickly! hope log helps. ian
first things first: think can vastly simplify layout using linearlayout:
<scrollview xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <linearlayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <imageview android:layout_width="match_parent" android:layout_height="wrap_content" android:scaletype="centercrop" android:src="@drawable/fhpaint"/> <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="16dp" android:gravity="center" android:text="@string/francisinfo"/> <imageview android:layout_width="match_parent" android:layout_height="wrap_content" android:scaletype="centercrop" android:src="@drawable/fhp"/> </linearlayout> </scrollview>
here's example screen shot:
next, you'll need view controller, known in android world fragment. among other lifecycle methods, fragments need override oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) in order display views. example:
@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view v = inflater.inflate(r.layout.fragment_layout, container, false); ... other code here ... return v; }
once you've implemented code above, should @ least see images , text.
Comments
Post a Comment