This document provides an overview of designing user interfaces for Android apps. It discusses:
- Using layout qualifiers to provide resources for different screen densities and sizes, such as -mdpi or -large.
- Implementing qualifiers by placing resources like layouts and bitmaps in folders like res/layout-small and res/drawable-hdpi.
- A hack to use dimensions defined in dimens.xml to set view widths and heights flexibly across screen densities without needing multiple layout files.
- The benefits of using this approach are that it reduces the need to create multiple layout files, but it has downsides like not being as precise as unique layout files.
21. If you think it’s a hassle to
calculate dp for all screen
densities, use
Dp
Calculator
h"ps://play.google.com/store/apps/details?
id=com.vivek.dpcalculator&hl=en
34. Navigation with Action bar
Utilize the main action bar for
displaying the current view title and
an up caret for navigating up a
hierarchy
Use tabs for navigating
through different views.
Use the bottom bar for
displaying actions
41. “How do I configure for
different screens then ?”
42. Layout Qualifier
These are configuration qualifiers.
Allow developers to control how the system
selects the alternative resources based on
characteristics of the current device screen.
Each screen characteristic has a
separate qualifier.
43. Screen Characteris-c Qualifier Descrip-on
Size
small
Resources
for
small
screen
sizes.
normal
Resources
for
normal
size
screens.
(Default)
large
Resources
for
large
size
screens.
xlarge
Resources
for
extra large
size
screens.
Density
ldpi
Resources
for
ldpi
screens.
mdpi
Resources
for
mdpi
screens.
hdpi
Resources
for
hdpi
screens.
xhdpi
Resources
for
xhdpi
screens.
tvdpi
Resources
for
screens
somewhere
between
mdpi
and
hdpi.
OrientaGon
land
Resources
for
landscape
orientaGon
port
Resources
for
potrait
orientaGon
Qualifier types
44. Screen Characteris-c Qualifier Descrip-on
Size
small
Resources
for
small
screen
sizes.
normal
Resources
for
normal
size
screens.
(Default)
large
Resources
for
large
size
screens.
xlarge
Resources
for
extra large
size
screens.
Density
ldpi
Resources
for
ldpi
screens.
mdpi
Resources
for
mdpi
screens.
hdpi
Resources
for
hdpi
screens.
xhdpi
Resources
for
xhdpi
screens.
tvdpi
Resources
for
screens
somewhere
between
mdpi
and
hdpi.
OrientaGon
land
Resources
for
landscape
orientaGon
port
Resources
for
potrait
orientaGon
Qualifier types
45. Implementing qualifiers
res/layout/my_layout.xml // layout for normal
screen size ("default")
res/layout-small/my_layout.xml // layout for small
screen size
res/layout-large/my_layout.xml // layout for large
screen size
res/layout-xlarge/my_layout.xml // layout for extra
large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra
large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium
density
res/drawable-hdpi/my_icon.png // bitmap for high
density
res/drawable-xhdpi/my_icon.png // bitmap for extra
high density use
mdpi,
etc
for
bitmaps
and
small,
etc
for
layouts
46. Good
implementation
practice
But how's got time for that ??
Also in the manifest file:
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
47. Hack
When declaring Views use the dimen to
give away dimensions.
e.g.
<Button
android:layout_width = “@dimen/button_width”
…/>
How
do
I
refer
?
How
do
I
do
this
?
Where
is
this
?
49. Create different values
folder with different
qualifiers
Give out different
dimensions according
to screen sizes
And PRESTO !
You are done for now
But there is a
downside to this.