
这个例子: http://hotelreservbyvic.comli.com/whatineed.jpg我的代码在这里:
linearLayout l_layout = (linearLayout) findVIEwByID(R.ID.linear_vIEw_report); LayoutParams param = new linearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT,1.0f); ImageVIEw[] imgvIEw=new ImageVIEw[questions.length]; for(int i=0;i<no_of_questions;i++) { if(userEnteredAnswers[i]==correct_answer[i]){ Bitmap bm=BitmapFactory.decodeResource(getResources(),R.drawable.correct); Canvas canvas = new Canvas(bm); Paint paint = new Paint(); paint.setcolor(color.BLACK); paint.setTextSize(10); canvas.drawText(i,5,paint); imgvIEw[i]=new ImageVIEw(this); imgvIEw[i].setimageDrawable(new BitmapDrawable(bm)); l_layout.addVIEw(imgvIEw[i]); } else { Bitmap bm=BitmapFactory.decodeResource(getResources(),R.drawable.wrong); Canvas canvas = new Canvas(bm); Paint paint = new Paint(); paint.setcolor(color.BLACK); paint.setTextSize(10); canvas.drawText(i,paint); imgvIEw[i]=new ImageVIEw(this); imgvIEw[i].setimageDrawable(new BitmapDrawable(bm)); l_layout.addVIEw(imgvIEw[i]); } } 我得到这个警告:
The constructor BitmapDrawable(Bitmap) is deprecated
运行时没有图像显示.
我究竟做错了什么?
例如:
TextVIEw t = (TextVIEw)findVIEwByID(R.ID.my_text_vIEw);// setting gravity to "center"t.setGravity(Gravity.CENTER);t.setBackgroundResource(R.drawable.my_drawable);t.setText("FOO"); 总结 以上是内存溢出为你收集整理的java – 如何在android编码中的ImageView上写文本?全部内容,希望文章能够帮你解决java – 如何在android编码中的ImageView上写文本?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)