Why ImageView doesn't show up inside ScrollView

by Frank » Fri, 20 May 2011 09:34:05 GMT


Sponsored Links
 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 extends ScrollView {

    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);
        ImageView iv = new ImageView(getContext());
        iv.setLayoutParams( new LinearLayout.LayoutParams(width, height) );
        iv.setImageBitmap(bmp);
        iv.setScaleType(ImageView.ScaleType.CENTER);
        addView(iv);
    }
}


However, if I derive MyCtrl from ImageView directly, the white image
shows up.

Your help is highly appreciated.

Cheers,
Frank

-- 



Re: Why ImageView doesn't show up inside ScrollView

by Mark Murphy » Fri, 20 May 2011 18:04:28 GMT


 Why are you using LinearLayout.LayoutParams for a child of a
ScrollView subclass?






-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://github.com/commonsguy 
 http://commonsware.com/blog  |  http://twitter.com/commonsguy 

Android App Developer Books:  http://commonsware.com/books 

-- 


Sponsored Links


Other Threads

1. is here the right place for my question ?

because I can't find elsewhere

my question is about the google maps application on android 2.1 (or more)

the pb is with an proprietary web application to send the adress of the médical intervention for SOS Médecins

sometime when I clic on the adress in the web page the system ask if i want to open map with the search on a part of the text (with airport in it for example)

I would like to know if there is a simple syntax/tag to define some text as an adress to trigger the use of google maps ?

is here the right forum and if not is somebody kind enough to give me some clue where to ask ?

thank you a lot


--
JF Pion "If a cluttered desk is sign of a cluttered mind, of what, then, is an empty desk a sign ? " Albert Einstein

Errare humanum est, perseverare politicum



--

2. Twitter App Source Code

Where can I find the source code for the Android Twitter App?

Thanks

Zach

-- 

3. how do I create an executable file from a working android project with eclipse?

4. How to detect presence of camera on an Android device.

5. Problem with map overlay

6. Android 2.2 challenges the iPhone 4 to a JavaScript duel鈥?and wins!

7. App Not Visible On Donut