Android ignoring my setWidth() and setHeight()

Posted by popoffka on Stack Overflow See other posts from Stack Overflow or by popoffka
Published on 2010-05-04T12:46:08Z Indexed on 2010/05/04 16:38 UTC
Read the original article Hit count: 324

Filed under:
|
|
|

So, why does this code:

package org.popoffka.apicross;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;

public class Game extends Activity {
 @Override
 protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     Button testButton = new Button(this);
     testButton.setBackgroundResource(R.drawable.cell);
     testButton.setWidth(20);
     testButton.setHeight(20);
     setContentView(testButton);
 }
}

...produce this thing: http://i42.tinypic.com/2hgdzme.png even though there's a setWidth(20) and setHeight(20) in the code? (R.drawable.cell is actually a 20x20 PNG image containing a white cell with a silver border)

© Stack Overflow or respective owner

Related posts about android

Related posts about view