PV239 #android2
cv4
Marek Sedlak
@msed__
CUSTOMIZATION
CUSTOMIZATION
● Styles
○ Custom views
● Themes
○ Custom app-wide looks
● Various build types
○ Debug, release, various optimizations
● Flavors
○ If you need to clone your app
STYLES
Styles
● A style is a collection of attributes that specify the look and format for a View or
window.
● When to use?
○ Couple of screens with multiple text formats
○ Many buttons (and you want to style them)
○ etc
● You can extend styles (parents)
● Button example (styles.xml)
● Usage (layout/fragment/view.xml)
Styles
● Color
○ colors.xml file
○ android:background="@color/colorCloseButtonBackground"
● Shape
○ xml file in drawable
○ gradients, strokes, ...
○ android:background="@drawable/myViewBackground"
● Selector
○ mainly buttons (various states)
○ states defined in xml
● Various displays
Styles
● Shape (xml file in drawable/)
● Selector (xml file in drawable/)
Shape & Selector
THEMES
Themes
● A theme is a style applied to an entire Activity or app, rather than an individual
View (styles.xml)
Themes
http://www.viralandroid.com/2015/08/android-custom-material-design-theme-color.html
Themes - how to apply the theme
● In AndroidManifest.xml
...
CUSTOM APK OUTPUTS
Build types
● A configuration for binary output.
● Build.gradle:
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
signingConfig signingConfigs.debug
applicationIdSuffix ".debug"
}
release {
minifyEnabled true // use proguard
shrinkResources true // remove unused resources
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
Signing Configs
● Signing configs allow us to sign various build types with custom keys..
● Build.gradle:
signingConfigs {
// it is not safe to store passwords here but you get the idea :)
// check the git repository ;)
debug {
storeFile file('../extras/keystore/release.jks')
keyAlias 'android'
storePassword 'android'
keyPassword 'android'
}
release {
storeFile file('../extras/keystore/release.jks')
keyAlias 'android'
storePassword 'android'
keyPassword 'android'
}
}
Flavors
● A product flavor defines a customized version of the application build by the
project.
● build.gradle:
productFlavors {
demo {
applicationIdSuffix ".demo"
versionNameSuffix "-demo"
}
full {
applicationIdSuffix ".full"
versionNameSuffix "-full"
}
}
Build.gradle
● buildToolsVersion (your build tools version - android sdk manager; 25.0.2)
● compileSdkVersion (you should always use the latest; 25)
● targetSdkVersion (tested up to; 25)
● minSdkVersion (minimum api level, where the app is able tu run; 15)
● applicationId (reverse organisation + project codename;
cz.muni.pv239.marek.cv4)
● versionCode (increase with every deploy; 1)
● versionName (whatever you like - visible to the user; “1.0.0-SNAPSHOT”)
EXAMPLES IN GIT
THANK YOU
See you on Slack.