Skip to content

A utility class for dynamically setting view object sizes based on a percentage of the device screen size. Think responsive design for android.

Notifications You must be signed in to change notification settings

skumar2998/ScreenUtility

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

##Android Screen Utility

A utility class for dynamically setting view object height and width based on percentages of the total screen height and width.

This has saved me a lot of time creating layouts that look good across different screen sizes, but it doesn't look very good on larger devices such as tablets.

##Using this class

  1. Add the class to your package and change the package line at the top:
package com.my.package;
  1. Create an instance of this class:
ScreenUtility utility = new ScreenUtility(this);

(We need to pass the current activity to it in the constructor)

  1. Declare your view objects, for example a button:
Button myButton = (Button)findViewById(R.id.mybutton);
  1. Set its dimensions!
 int width = 100;
 int height = 20;
 utility.setViewObjectDimensionsAsPercentage(height, width, myButton);

The view object will now be the size you gave it, in percentage, of the total height and width of the screen size.

About

A utility class for dynamically setting view object sizes based on a percentage of the device screen size. Think responsive design for android.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published