Why are elements from my Android RelativeLayout not showing up when inflated in ListView? -
i have custom view i've put that's kind of supposed google cards. here's looks in android studio:
ignore fact android studio renders rest of screen around it; view rectangle bounded dropshadow @ bottom of it. if set main content view , inflate 1 @ runtime, looks correct. if inflate 1 part of listview @ runtime, looks this:
the thing views disappeared seem have in common attached things other edge of layout. here's layout:
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="340dp" android:layout_height="260dp" android:cliptopadding="true" android:background="@drawable/card_background" android:minheight="260dp" android:minwidth="340dp"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancelarge" android:text="4" android:id="@+id/textbeat" android:fontfamily="sans-serif-light" android:textsize="80sp" android:textcolor="@android:color/holo_red_light" android:layout_above="@+id/linearlayout" android:layout_alignright="@+id/buttonmenu"/> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancemedium" android:text="card title" android:id="@+id/texttitle" android:layout_alignparentleft="true" android:layout_marginleft="12dp" android:textcolor="@android:color/darker_gray" android:fontfamily="sans-serif-light" android:maxwidth="280dp" android:layout_alignparenttop="true" android:layout_margintop="12dp" android:textsize="36sp" android:maxheight="96dp" android:ellipsize="end"/> <linearlayout android:layout_width="fill_parent" android:layout_height="48dp" android:layout_alignparentbottom="true" android:layout_centerhorizontal="true" android:id="@+id/linearlayout"> <imagebutton android:layout_width="wrap_content" android:layout_height="fill_parent" android:id="@+id/buttontoggle" android:layout_weight="1" android:background="@android:color/transparent" android:src="@drawable/ic_launcher"/> <view android:layout_width="1dp" android:layout_height="fill_parent" android:layout_margintop="8dp" android:layout_marginbottom="8dp" android:background="@android:color/darker_gray"/> <imagebutton android:layout_width="wrap_content" android:layout_height="fill_parent" android:id="@+id/buttondelete" android:layout_weight="1" android:background="@android:color/transparent" android:src="@drawable/ic_launcher"/> </linearlayout> <imagebutton android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_launcher" android:background="@android:color/transparent" android:onclick="showpopup" android:layout_alignparenttop="true" android:layout_alignparentright="true" android:layout_margintop="12dp" android:layout_marginright="12dp" android:id="@+id/buttonmenu"/> <button android:layout_width="48dp" android:layout_height="48dp" android:text="200" android:id="@+id/buttontempo" android:layout_above="@+id/linearlayout" android:layout_alignleft="@+id/texttitle" android:background="@android:color/transparent" android:textcolor="@android:color/holo_blue_light"/> <button android:layout_width="48dp" android:layout_height="48dp" android:text="4" android:id="@+id/buttonsignature" android:background="@android:color/transparent" android:textcolor="@android:color/holo_blue_light" android:layout_above="@+id/linearlayout" android:layout_torightof="@+id/buttontempo"/> <button android:layout_width="48dp" android:layout_height="48dp" android:text="2" android:id="@+id/buttonsubdiv" android:background="@android:color/transparent" android:textcolor="@android:color/holo_blue_light" android:layout_above="@+id/linearlayout" android:layout_torightof="@+id/buttonsignature"/> <imageview android:layout_width="48dp" android:layout_height="48dp" android:id="@+id/icontempo" android:layout_above="@+id/buttontempo" android:layout_alignleft="@+id/buttontempo" android:src="@drawable/ic_launcher" android:paddingtop="8dp"/> <imageview android:layout_width="48dp" android:layout_height="48dp" android:id="@+id/iconsignature" android:src="@drawable/ic_launcher" android:layout_above="@+id/buttontempo" android:layout_torightof="@+id/buttontempo" android:paddingtop="8dp"/> <imageview android:layout_width="48dp" android:layout_height="48dp" android:id="@+id/iconsubdiv" android:src="@drawable/ic_launcher" android:layout_above="@+id/buttonsignature" android:layout_torightof="@+id/buttonsignature" android:paddingtop="8dp"/>
here's adapter:
public class cardadapter extends baseadapter { private static final string tag = "rhythmcards"; private final context mcontext; private final arraylist<card> mcards; public cardadapter(context context, arraylist<card> cards) { mcontext = context; mcards = cards; } static class viewholder { public textview title; public button tempo; public button signature; public button subdivision; public textview beat; } @override public view getview(int position, view convertview, viewgroup viewgroup) { viewholder holder; // if row passed in null, must inflate , populate new view. if (convertview == null) { layoutinflater inflater = (layoutinflater) mcontext.getsystemservice(context.layout_inflater_service); convertview = inflater.inflate(r.layout.card_layout, null); holder = new viewholder(); // put references views contained in card holder holder.title = (textview) convertview.findviewbyid(r.id.texttitle); holder.tempo = (button) convertview.findviewbyid(r.id.buttontempo); holder.signature = (button) convertview.findviewbyid(r.id.buttonsignature); holder.subdivision = (button) convertview.findviewbyid(r.id.buttonsubdiv); holder.beat = (textview) convertview.findviewbyid(r.id.textbeat); convertview.settag(holder); } else { // otherwise, use holder attached row passed in holder = (viewholder) convertview.gettag(); } return convertview; } @override public int getcount() { return mcards.size(); } @override public object getitem(int position) { return mcards.get(position); } @override public long getitemid(int position) { return position; } }
what keeping these views showing up?
Comments
Post a Comment