tags:

views:

12

answers:

1

Hello In my android application i am using a image as background initially. Then on top of that i need to place small images and on top of the small images i would like to place a textview with some text on it.

I am using below code for that.With this am able to place the small images but the textview if i am trying to place it place in the next row and not over the image. I also tried with adding the image as the background and then placing textview but at that case the padding and size of the image is not getting decreased.

      TableLayout table = (TableLayout)findViewById(R.id.FirstTable);
       TableRow tr = new TableRow(this);
      tr.setId(i);
      tr.setPadding(0, 25, 0, 10);
       ImageView imageView = new ImageView(this);
       imageView.setLayoutParams(new TableRow.LayoutParams(60, 60));

        imageView.setImageResource(R.drawable.bookicon);

        tr.addView(imageView);
          table.addView(tr);

Is there any way that i can have the images of size 60 by 60 and place a textview on top of these images.

Please share your valuable suggestions.

Thanks in advance:)

A: 

Have you tried to put your image in background of the TextView instead of trying to put it over an ImageView ? It's the standard way to put text over an image.

Now if you really need to put a TextView over an ImageView, and that really needs to be an ImageView, you can do it by putting the TextView and the ImageView together in a FrameLayout, like this:

<FrameLayout ...>
  <ImageView android:src="" ... />
  <TextView ... />
</FrameLayout>

...or the equivalent code. And put the FrameLayout in your table.

Jean
Thanks Jean.It works
Remmyabhavan