我想在活动运行时显示图像和文本。同样就像在 WHATSAPP 中发生的聊天一样。我在 textview 中显示文本,在 imageview 中显示图像。我面临的问题是我想用滚动在同一个活动中显示它们例如:
image
text
text
image
text
image
image
我应该使用哪种布局或控件来显示这样的内容?
像这样添加两者..
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);