在运行时显示图像和文本,android?

在运行时显示图像和文本,android?,android,textview,imageview,runtime,Android,Textview,Imageview,Runtime,我想在活动运行时显示图像和文本。 类似地,就像WHATSAPP中发生的聊天一样。 我在textview中显示文本,在imageview中显示图像。 我面临的问题是,我想用scroll在同一活动中同时显示这两个项目 例如: 我应该使用哪种布局或控件来显示这样的内容?像这样添加这两种内容 LinearLayout linearLayout=new LinearLayout(this); linearLayout.setOrientation(LinearLayout.HORIZONTAL); L

我想在活动运行时显示图像和文本。 类似地,就像WHATSAPP中发生的聊天一样。 我在textview中显示文本,在imageview中显示图像。 我面临的问题是,我想用scroll在同一活动中同时显示这两个项目 例如:

我应该使用哪种布局或控件来显示这样的内容?

像这样添加这两种内容

LinearLayout linearLayout=new LinearLayout(this);
 linearLayout.setOrientation(LinearLayout.HORIZONTAL);
 LinearLayout.LayoutParams vp=new   
 LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);

TextView tv = new TextView(this);
tv.settext("test");
linearLayout.addView(imageView,tv);

ImageView imageView= new ImageView(this);
imageView.setImageBitmap(bitMap);
imageView.setVisibility(View.VISIBLE);
imageView.setBackgroundColor(0xFFFF00FF);
//linearLayout=LinearLayout+imageView;
LinearLayout.LayoutParams Iv=new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
linearLayout.addView(imageView,Iv);
setContentView(linearLayout,vp);

从Android教程开始应该可以做到这一点。
LinearLayout linearLayout=new LinearLayout(this);
 linearLayout.setOrientation(LinearLayout.HORIZONTAL);
 LinearLayout.LayoutParams vp=new   
 LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);

TextView tv = new TextView(this);
tv.settext("test");
linearLayout.addView(imageView,tv);

ImageView imageView= new ImageView(this);
imageView.setImageBitmap(bitMap);
imageView.setVisibility(View.VISIBLE);
imageView.setBackgroundColor(0xFFFF00FF);
//linearLayout=LinearLayout+imageView;
LinearLayout.LayoutParams Iv=new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
linearLayout.addView(imageView,Iv);
setContentView(linearLayout,vp);