I want to add some images to the View of an app. The app uses a custom view for its normal working but I want some images along with the custom View. I have tried adding a Layout as the contenView in which I added the ImageView and the custom View, but its not comming to the screen.
Can any one give me some idea on this...
thanks in advance.
Code:
MyView view;
LinearLayout ly;
LinearLayout.LayoutParams lp;
LinearLayout.LayoutParams ImageViewlp;
lp=new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
ImageViewlp=new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
ly=new LinearLayout(this);
sketchBoard.setBackgroundColor(0);
ImageView img=new ImageView(this);
img.setBackgroundColor(R.drawable.img);
ly.addView(img,ImageViewlp);
view=new MyView(this);
ly.addView(view);
this.addContentView(ly, lp);
Edit:
img.setBackgroundResource(R.drawable.img);
I got it solved by changing img.setBackgroundColor(R.drawable.img);
with the above one
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…