Get the size of Default Display Screen : Screen « Hardware « Android






Get the size of Default Display Screen

   
package app.test;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.ImageView;

public class Test extends Activity {
  ImageView drawingImageView;
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    drawingImageView = (ImageView) this.findViewById(R.id.DrawingImageView);
    Bitmap bitmap = Bitmap.createBitmap((int) getWindowManager()
        .getDefaultDisplay().getWidth(), (int) getWindowManager()
        .getDefaultDisplay().getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    drawingImageView.setImageBitmap(bitmap);

    Paint paint = new Paint();
    paint.setColor(Color.GREEN);
    paint.setTextSize(20);
    paint.setTypeface(Typeface.DEFAULT);
    Path p = new Path();
    p.moveTo(20, 20);
    p.lineTo(100, 150);
    p.lineTo(200, 220);
    canvas.drawTextOnPath("this is a test", p, 0, 0, paint);
  }
}

   
    
    
  








Related examples in the same category

1.Multiscreen size
2.Nested PreferenceScreen
3.Screen Orientation
4.Rows have different number of columns and content doesn't fit on screen: column 4 of row 2 shrinks all of the other columns
5.Demonstrates the Tab scrolling when too many tabs are displayed to fit in the screen.
6.Using PreferenceScreen
7.Splash Screen
8.Get the optimal preview size for the given screen size.
9.Methods for converting between the physics world coordinates and the screen coordinates.
10.Get screen Orientation
11.add Home Screen Shortcut
12.Return the supported picture size that best fits on the device screen.
13.Screen Short
14.Set full screen mode