Skip to content

Commit

Permalink
Updated README and renamed test class
Browse files Browse the repository at this point in the history
  • Loading branch information
yesitskev committed Feb 2, 2017
1 parent 12c47c9 commit 03fb2be
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 10 deletions.
47 changes: 38 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,64 @@
Android Units
==========

A utility class for converting between different Android display units
A utility class for converting between different Android display units without requiring an
application context. This uses the system global shared `Resources` object and is not configured for
the current screen (can not use dimension units, does not change based on orientation, etc).

In future iterations of this utility I would like to accommodate to above changes.



Example Usage
-------------

How can I get the pixels for the display pixel (dp) measurement I have?
Lets say you want to set the text size while drawing a custom view:
```java
paint.setTextSize(AndroidUnits.SCALED_PIXELS.toPixels(8));
```

Or you want to draw a rectangle with rounded corners:
```java
float topPaddingOrSomething = AndroidUnits.DENSITY_PIXELS.toPixels(8);
float radius = AndroidUnits.DENSITY_PIXELS.toPixels(12);
canvas.drawRoundRect(rect, radius, radius, paint);
```


Download
--------

Add via Gradle:


```groovy
compile 'com.github.kevelbreh:androidunits:0.1.0'
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
compile 'com.github.kevelbreh:androidunits:0.1.0'
}
```
or Maven:

Or Maven:

```xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependency>
<groupId>com.github.kevelbre</groupId>
<artifactId>androidunits</artifactId>
<version>0.1.0</version>
<groupId>com.github.kevelbreh</groupId>
<artifactId>androidunits</artifactId>
<version>0.1.0</version>
</dependency>
```

```

License
-------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import static org.junit.Assert.assertEquals;

@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
public class ConversationsInstrumentedTest {

@Test public void conversions() throws Exception {
DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
Expand Down

0 comments on commit 03fb2be

Please sign in to comment.