在代码中添加
创建一个新的layout newL, 将imageview加到newL, 再将newL加入到xml中定义的layout.
ViewGroup.LayoutParams lp_fullWidth =new ViewGroup.LayoutParams(lWidth, lHeight);ViewGroup.LayoutParams lp_wrap =new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, lHeight);
LinearLayout layout = (LinearLayout) findViewById(R.id.viewNowPlaying);LinearLayout newL = new LinearLayout(context); // create layoutImageView arrowRT = new ImageView(context); // create imagearrowRT.setImageResource(R.drawable.arrowrt); // set source filenewL.addView(arrowRT, lp_wrap); // add image to newLlayout.addView(newL,lp_fullWidth); // add newL to layout
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(1)
创建一个新的layout newL, 将imageview加到newL, 再将newL加入到xml中定义的layout.
ViewGroup.LayoutParams lp_fullWidth =
new ViewGroup.LayoutParams(lWidth, lHeight);
ViewGroup.LayoutParams lp_wrap =
new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, lHeight);
LinearLayout layout = (LinearLayout) findViewById(R.id.viewNowPlaying);
LinearLayout newL = new LinearLayout(context); // create layout
ImageView arrowRT = new ImageView(context); // create image
arrowRT.setImageResource(R.drawable.arrowrt); // set source file
newL.addView(arrowRT, lp_wrap); // add image to newL
layout.addView(newL,lp_fullWidth); // add newL to layout