I have created ImageView by dynamically and I want to set one TextView to top of the ImageView by programatically.
This is my code.
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
Bitmap bm = BitmapFactory.decodeResource(getResources(),
R.drawable.ic_launcher);
chatHead = new ImageView(this);
num = new TextView(this);
chatHead.setImageBitmap(getCircleBitmap(bm, 200));
final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
params.gravity = Gravity.TOP | Gravity.LEFT;
params.x = 0;
params.y = 100;
windowManager.addView(chatHead, params);
Use same params for textview also :
windowManager.addView(num, params);
It will show the textview on image.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.