Thank you, Mark,  for the reply.

For of all, I am pretty new to Android and my code is by no means
doing things in the most meaningful way. :)
Before answering your question, can I ask does using
LinearLayout.LayoutParams prevent it from working? I tried to comment
it out, but it still doesn't work.

In fact, this is just a trial code. What I really want to do is to
tile a ViewGroup with a whole bunch of ImageViews. I want to specify
the absolute location and dimensions of each ImageView inside the
parent ViewGroup. However, it looks to me that I cannot do this. I
found there is AbsoluteLayout, but it is deprecated. So do you know of
any option to achieve this?

Thank you very much.

Frank

On May 20, 3:03 am, Mark Murphy <[email protected]> wrote:
> Why are you using LinearLayout.LayoutParams for a child of 
> aScrollViewsubclass?
>
>
>
>
>
>
>
>
>
> On Thu, May 19, 2011 at 9:21 PM, Frank <[email protected]> wrote:
> > Hi All,
>
> > I have the following code. I only got a black screen without seeing
> > the white image.
>
> > public class Demo extends Activity {
> >    private MyCtrl mCtrl;
> >    protected void onCreate(Bundle savedInstanceState) {
> >        super.onCreate(savedInstanceState);
>
> >        mCtrl = new MyCtrl(this);
> >        setContentView(mCtrl);
> >    }
> > }
>
> > public class MyCtrl extendsScrollView{
>
> >    public MyCtrl (Context context) {
> >        super(context);
> >        setFocusable(true);
>
> >        int width = 100;
> >        int height = 100;
> >        int size = width * height;
> >        int buf[] = new int[size];
> >        for ( int i = 0; i < size; ++i) {
> >                buf[i] = 0xFFFFFFFF; //white image
> >        }
>
> >        Bitmap bmp = Bitmap.createBitmap(buf, width, height,
> > Bitmap.Config.ARGB_4444);
> >        ImageViewiv = newImageView(getContext());
> >        iv.setLayoutParams( new LinearLayout.LayoutParams(width, height) );
> >        iv.setImageBitmap(bmp);
> >        iv.setScaleType(ImageView.ScaleType.CENTER);
> >        addView(iv);
> >    }
> > }
>
> > However, if I derive MyCtrl fromImageViewdirectly, the white image
> > shows up.
>
> > Your help is highly appreciated.
>
> > Cheers,
> > Frank
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> Android App Developer Books:http://commonsware.com/books

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to