android - how to add image view and text view to a linear layout -


Follow my XML I want to see the image and add text to programmically delivered XML.

   

But I need output like programm, that is, a linear layout has image view and old text view and that the linear layout below add to the new text view.

  & lt; ? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; LinearLayout xmlns: android = "Http://schemaskandroidkcom/apk/res/android" Android: Layout_width = "Fill_parent" Android: Layout_height = "Fill_parent" android: orientation = "vertical" android: padding = "25dip" & Gt; & Lt; TextView android: id = "@ + name" Android: Layout_width = "Wrap_content" Android: Layout_height = "Wrap_content" Android: Layout_marginBottom = "L2dip" android: text = "@ string / app_name" Android: textSize = "24.5sp" / & Gt; & Lt; LinearLayout Android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: orientation = "horizontal" Android: padding = "25dip" & gt; & Lt; imageView Android: layout_width = "wrap_content" Android: layout_height = "60dp" Android: layout_marginBottom = "12dip" android: src = "@ drawable / app_icon_big" / & gt; & Lt; TextView Android: AD = "@ + Text1" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: layout_marginbottom = "12dip" Android: text = "@ string / app_name" Android: text size = "24.5sp "/ & Gt; & Lt; / LinearLayout & gt; & Lt; / LinearLayout & gt;  

Try this way, hope it solves your problem Will help you

main.xml

& lt; LinearLayout xmlns: android = "http://schemas.android.com/apk / res / android" android: id = "@ + id / outerLinearLayout" Android: layout_width = "match_parent" Android: layout_height = "match_parent" android: orientation = "Vertical" Android: padding = "25dp" & gt; Android: layout_height = "wrap_content" Android: Layout_marginBottom = "L2dp" android: text = "@ string / app_name" Android: textSize = "android: text =" 24.5sp "/ & gt; & Lt; / LinearLayout & gt; < / Code>

MainActivity.java

  increases the public class MyActivity activity {Private LinearLayout External Leaner Layout; Private Text View Lesson 1; @ Override Protected Zero to Create (Bundle Saved Instantstate) {Super.Nook (Saved Instantstate); setContentView (R.layout.main); External Linerout = (Linear Loyout) VVBiID (Route linearlayoutout); Text1 = (text view) searchVBIID (RaidText1); LinearLayout inner liner layout = new linearlayout (this); ImageView imageView = New ImageView (this); LinearLayout.LayoutParams parameter = new LinearLayout LayoutParams (LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.bottomMargin = 12; imageView.setLayoutParams (image); imageView.setScaleType (ImageView.ScaleType.FIT_XY); ImageView.setImageResource (R.drawable.ic_launcher); InnerLinearLayout.addView (imageView); TextView textView = new text view (this); TextView.setTextSize (float) 24.5); TextView.setText ("see new text"); TextView.setLayoutParams (parameter); OuterLinearLayout.removeAllViews (); InnerLinearLayout.addView (text1); OuterLinearLayout.addView (TextView); OuterLinearLayout.addView (innerLinearLayout); }}  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -