On Android, I am trying to create a dynamic image viewer that flip images and at the bottom of each image I display some information about the image,1 or 2 lines of text max. I want to give the area that displays the text a unique background color to let it stand up. Everything works fine with the exception of one thing, when I set a color for TextView to let say “Black” I get the entire screen black covering the image image! and not only the TextView area. Please bear in mind that I create everything dynamically as I am doing below:
imageFrame = new FrameLayout(this);
Viewer = new ImageView(this);
imageInfo = new TextView(this);
imageInfo.setHeight(imageInfo.getLineHeight()); imageInfo.setGravity(Gravity.BOTTOM);
imageInfo.setBackgroundColor(Color.CYAN);
imageFrame.addView(Viewer);
imageFrame.addView(imageInfo);
Any help is appreciated
You might want to set the height and width dynamically as well. My guess is the textview width and height are set to fill_parent. If that doesn’t work try adding the elements to the imageFrame in a different order.
Below is how you need to set the widths dynamically for each textview.
Also try making a linear layout the root element inside your frame layout. Then put the textview and image view in the linear layout.