java - Putting Custom View Inside a Custom ScrollView -
i creating android app customized view , customized scrollview
. attempting put custom view inside of scroll view. not appear work, receiving blank screen.
dashboard.java
package com.commentblock.fandoms; import com.commentblock.fandom.r; import com.commentblock.fandom.r.layout; import android.app.activity; import android.content.intent; import android.content.sharedpreferences; import android.os.bundle; import android.view.keyevent; import android.view.menu; import android.view.menuinflater; import android.view.menuitem; import android.view.viewgroup.layoutparams; import android.view.window; import android.widget.linearlayout; import android.widget.scrollview; import android.widget.toast; public class dashboard extends activity { protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); //set content view dashbaord this.requestwindowfeature(window.feature_no_title); this.setcontentview(new statusviewscroll(this)); } }
statusviewscroll.java
package com.commentblock.fandoms; import android.content.context; import android.view.view; import android.widget.relativelayout; import android.widget.scrollview; public class statusviewscroll extends relativelayout { public statusviewscroll(context c) { super(c); scrollview scrollview = new scrollview(c); statusview statusview = new statusview(c); scrollview.addview(statusview); addview(scrollview); } }
statusview.java
works fine without scrollview
, when add scrollview
, breaks. no errors, black screen.
i have fixed issue on own. problem lies @ statusview.java, needed override onmeasure event.
@override protected void onmeasure(int widthmeasurespec, int heightmeasurespec) { super.onmeasure(widthmeasurespec, heightmeasurespec); windowmanager wm = (windowmanager) this.getcontext().getsystemservice(context.window_service); display display = wm.getdefaultdisplay(); setmeasureddimension(display.getwidth(), display.getheight()); }
Comments
Post a Comment