Skip to content

Instantly share code, notes, and snippets.

@vmlinz
Last active August 29, 2015 14:24
Show Gist options
  • Save vmlinz/efc81b5160d064ab6ea8 to your computer and use it in GitHub Desktop.
Save vmlinz/efc81b5160d064ab6ea8 to your computer and use it in GitHub Desktop.
Android gradle notes

Various notes on Android

Gradle

Build.gradle attributes will override the ones in Manifest.xml

Manifest.xml build.gradle
package applicationId
minSdkVersion minSdkVersion
targetSdkVersion targetSdkVersion
versionCode versionCode
versionName versionName

Resources

Since a strings resource XML file is an XML file, if your message contains <, >, or & characters (other than the formatting tags listed above), you will need to use a CDATA section

<string name="report_body"> <![CDATA[
<html>
<body>
<h1>TPS Report for: {{reportDate}}</h1>
<p>Here are the contents of the TPS report:</p>
<p>{{message}}</p>
<p>If you have any questions regarding this report, please
do <b>not</b> ask Mark Murphy.</p>
</body>
</html>
]]>
</string>

Drawable dpis

ldpi mdpi hdpi xhdpi xxhdpi xxxhdpi
120 160 240 320 480 640

Dimension units

units px in/mm pt dip sp
descriptions hardware pixels inches and millimeters 1/72nd of an inch density-independent pixels scaled pixels, where one sp equals one dip for normal font scale levels, increasing and decreasing as needed based upon the user’s chosen font scale level in Settings
depends on screen density Y Y Y N N

View and widget system

The widget box model

Just like the css box model, https://developer.mozilla.org/en-US/docs/Web/CSS/box_model, Android widget system has the 
same concept of box model.

Layouts

LinearLayout

  • Properties: Orientation, Fill Model, Weight, Gravity
  • LinearLayout takes an “eldest child wins” approach towards allocating space. So, if we have a LinearLayout with three children, the 8rst child will get its requested space.
  • Android has two types of gravity: the gravity of a widget within a LinearLayout, and the gravity of the contents of a widget or container.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment