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. Java bytecode question (help greatly appreciated!)

Gotcha, thanks. This is how the fixed version looks like:

.source byteCode.j
.class public byteCode
.super java/lang/Object

.method public <init>()V
    invokenonvirtual java/lang/Object/<init>()V
.end method

.method public static main([Ljava/lang/String;)V

    .limit locals 4
    .limit stack 3

    getstatic java/lang/System/out Ljava/io/PrintStream;

    bipush 42
    istore 1

    iload 1
    iinc 1 7
    invokestatic java/lang/String/valueOf(I)Ljava/lang/String;
    astore 2

    aload 2
    invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V


.end method



2. Logs in a File

Hi All,

Iam Writing an Application in which i need to put all the system.out or
log.e logs into a file which will be generated in the phone system.

Please let me know how to do that ?
I would really appreciate that?

thanks and regards
#Ashish Dhiman#


3. Java bytecode question (help greatly appreciated!)

4. Customer signature

5. bad sqlite performance

6. WVGA soft keyboard

7. Android SDK 1.5 Voice recognition sample