Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

How get bitmap dimension without loading Android example

Bitmap Width, Height without memory allocation:

BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(getResources(), R.id.myimage, options);
// now opts.outWidth and opts.outHeight are the dimension of the
// bitmap, even though Bitmap is null
int imageHeight = options.outHeight;
int imageWidth = options.outWidth;
String imageType = options.outMimeType;

396LW NO topic_id




AD

Další témata ....(Topics)


143

Rounded rect RectF Android example | rounded-rect-rectf-android-example


RectF, drawRoundRect(),

public class MainActivity extends Activity {
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new SampleView(this));
	}

	private static class SampleView extends View {

		// CONSTRUCTOR
		public SampleView(Context context) {
			super(context);
			setFocusable(true);

		}
		@Override
		protected void onDraw(Canvas canvas) {
			Paint paint = new Paint();
			
			canvas.drawColor(Color.GREEN);
            
           Bitmap b = Bitmap.createBitmap(200, 200, Bitmap.Config.ALPHA_8);
           Canvas c = new Canvas(b);
           RectF rectF = new RectF();
           rectF.set(5,5,150,150);
           c.drawRoundRect(rectF, 10, 10, paint);
           
            paint.setColor(Color.RED);
           
           canvas.drawBitmap(b, 10,10, paint);
		}

	}
}


android/draw-rounded-rect-android.png
30

Alert messagebox toast Android example code | alert-messagebox-toast-android-example-code


Toast in Android application is equivalent of Alert in JavaScript or MessageBox in WinApi.


// Toast android.widget.Toast.makeText(Context context, CharSequence text, int duration)
// public static Toast makeText (Context context, CharSequence text, int duration) 

Toast.makeText(getApplicationContext(), "Hello world!",
                  Toast.LENGTH_SHORT).show();

35

Android startup tutorial for developers video | android-startup-tutorial-for-developers-video


How install Android emulator on PC
//developer.android.com/sdk/installing.html

Download links:
Java Development Kit JDK download
Eclipse download
Android SDK download