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) {

        mCtrl = new MyCtrl(this);

public class MyCtrl extends ScrollView {

    public MyCtrl (Context context) {

        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,
        ImageView iv = new ImageView(getContext());
        iv.setLayoutParams( new LinearLayout.LayoutParams(width, height) );

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

Your help is highly appreciated.



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. Server timeouts while attempting download android source

Has anyone successfully downloaded the source?  I've tried using both
git as described here<http://git.source.android.com/> and repo as
described here<http://source.android.com/download/using-repo>.
In all cases I get the folllowing timeout.  However I am able to ping
the server.  Are they just under a very heavy load?
$ repo init -u git://android.git.kernel.org/platform/manifest.git
Getting repo ...
   from git://android.kernel.org/tools/repo.git
android.kernel.org[0:]: errno=Connection timed out
android.kernel.org[1:]: errno=Connection timed out
fatal: unable to connect a socket (Connection timed out)

$ ping
PING ( 56 data bytes
64 bytes from icmp_seq=0 ttl=57 time=59 ms
64 bytes from icmp_seq=1 ttl=57 time=45 ms
64 bytes from icmp_seq=2 ttl=57 time=45 ms
64 bytes from icmp_seq=3 ttl=57 time=52 ms
64 bytes from icmp_seq=4 ttl=57 time=45 ms
64 bytes from icmp_seq=5 ttl=57 time=44 ms
64 bytes from icmp_seq=6 ttl=57 time=45 ms
64 bytes from icmp_seq=7 ttl=57 time=46 ms
64 bytes from icmp_seq=8 ttl=57 time=44 ms
64 bytes from icmp_seq=9 ttl=57 time=44 ms
64 bytes from icmp_seq=10 ttl=57 time=44 ms
64 bytes from icmp_seq=11 ttl=57 time=44 ms

---- PING Statistics----
12 packets transmitted, 12 packets received, 0.0% packet loss
round-trip (ms)  min/avg/max/med = 44/46/59/45


2. Installing Android on different Handsets than G1?

Hi Group,

I'm living in Germany, so there is no access to the G1 right now. Also
as far as I know the G1 will come with a 2 year subscription from t-

So my idea is to deploy the Android System on another handset. I have
a spare Samsung I600 (comparable with the Samsung BlackJack 1) lying
here. So it should be possible to install Android on it (removing the
existing windows mobile).

Am I right? Is there any possibility? What - exept building Android -
do I have to do? Which requirements do I have to keep an eye on?

Are there any hints, links etc for me?



3. how the library files (c, c++) are linked with framework (java files)

4. How to make a desktop widget?

5. Cannot compile Android app: "Failed to create debug key"

6. need some inputs/help

7. how to test if the screen is in HVGA-L mode