Last active
November 11, 2016 08:21
-
-
Save quydm/06b47139b4853ba413c8a1d0d8b10a4b to your computer and use it in GitHub Desktop.
Create dimens.xml file with screen density
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$file = 'dimens.xml'; | |
$ratio = 1;// change ratio with screen density. Example: ratio = 1 for values, 1.5 for values-hdpi or values-sw600dp | |
$tab_size = ' '; | |
$str = '<?xml version="1.0" encoding="utf-8"?>' . PHP_EOL; | |
$str .= '<resources>' . PHP_EOL . PHP_EOL; | |
for ($i = 1; $i <= 600; $i ++) | |
$str .= $tab_size . '<dimen name="n' . $i . 'dp">' . ($i * $ratio) . 'dp</dimen>' . PHP_EOL; | |
for ($i = 12; $i <= 40; $i ++) | |
$str .= $tab_size . '<dimen name="n' . $i . 'sp">' . ($i * $ratio) . 'sp</dimen>' . PHP_EOL; | |
$str .= PHP_EOL . '</resources>'; | |
file_put_contents($file, $str); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment