GET SCREEN SIZE
SOURCE CODE is
package com.ScreenSizeExample;
import android.app.Activity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.widget.Toast;
public class ScreenSizeExample extends Activity
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);int height,width;
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
height = displaymetrics.heightPixels;
width = displaymetrics.widthPixels;
Toast msg = Toast.makeText(ScreenSizeExample.this,
"HEIGHT : "+height+"\nWIDTH : "+width, Toast.LENGTH_LONG);
msg.show();
}
}The OUTPUT will be
No comments:
Post a Comment