android - Add a list of TextViews and ImageViews to an existing RelativeView programmatically -
i have relativelayout
id of relative_layout_bottom
trying add content programmatically. looping through <textview, imageview>
dictionary , adding entries follows:
i want left side (align parent left) of relativelayout
have list of textviews
going downwards, , right side (align parent right) of relativelayout
have list of imageviews
going downwards this:
|textview#1 imageview#1| |textview#2 imageview#2| |textview#3 imageview#3| |textview#4 imageview#4| | . . | | . . | | . . |
i can't seem figure out how though, nothing showing me. can edit in code have if cares see i'm pretty sure it'd more useful come different solution fix mine.
here xml, using 1 textview , imageview going append to? not sure if works that, or if should programmatically make individual textview , imageview each entry.
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingtop="20dp" android:paddingleft="10dp" android:paddingright="10dp" tools:context="com.brettrosen.atls.activity.report"> <linearlayout android:id="@+id/report_top_layout" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:orientation="vertical"> <scrollview android:id="@+id/scroll_view_top" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <relativelayout android:layout_width="match_parent" android:layout_height="match_parent"> <textview android:id="@+id/checkbox_time" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true"/> </relativelayout> </scrollview> </linearlayout> <linearlayout android:id="@+id/report_bottom_layout" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:orientation="vertical"> <scrollview android:id="@+id/scroll_view_bottom" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <relativelayout android:id="@+id/relative_layout_bottom" android:layout_width="match_parent" android:layout_height="match_parent"> <textview android:id="@+id/checkbox_text_bottom" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true"/> <imageview android:id="@+id/checkbox_notes" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentright="true"/> /> </relativelayout> </scrollview> </linearlayout>
here's code have far:
textview checkbox_text_bottom = (textview) findviewbyid(r.id.checkbox_text_bottom); relativelayout relativelayout = (relativelayout) findviewbyid(r.id.relative_layout_bottom); (map.entry entry : prearrivalplan.imagebuttonswithnotes.entryset()) { imagebutton imagebutton = (imagebutton) entry.getvalue(); bitmap bitmap = drawabletobitmap(imagebutton.getbackground()); checkbox_text_bottom.append(entry.getvalue() + "\n"); // append text textview imageview image = new imageview(report.this); // create imageview image.setimagebitmap(bitmap); relativelayout.layoutparams params = (relativelayout.layoutparams)image.getlayoutparams(); params.addrule(relativelayout.align_parent_right); image.setlayoutparams(params); relativelayout.addview(image); // add layout }
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context=".mainactivity"> <scrollview android:layout_width="wrap_content" android:layout_height="wrap_content"> <relativelayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <linearlayout android:id="@+id/linlayleft" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:orientation="vertical"> </linearlayout> <linearlayout android:id="@+id/linlayright" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentright="true" android:orientation="vertical"> </linearlayout> </relativelayout> </scrollview> </relativelayout> u can add widgets in respective linearlayout using addview.
Comments
Post a Comment