Lesson 13 App UI Design
Lesson 13 App UI Design
App UI design
View
attributes Overrides this
Style
Overrides this
Theme
In layout file:
<ConstraintLayout …
android:theme="@style/Theme.MyApp">
<LinearLayout …
android:background="?attr/colorSurface">
<TextView
style="@style/DescriptionStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/description_text" />
<style name="DescriptionStyle">
<item name="android:textColor">?attr/colorOnSurface</item>
<item name="android:textSize">16sp</item>
...
</style>
android:textAppearance="@style/TextAppearance.MaterialComponents.Headli
ne1"
android:text="@string/title" />
<TextView
...
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1
android:text="@string/body_text" />
parent="TextAppearance.MaterialComponents.Headline1">
...
<item name="android:textStyle">normal</item>
<item name="android:textAllCaps">false</item>
<item name="android:textSize">64sp</item>
<item name="android:letterSpacing">0</item>
...
</style>
Adaptable system of
guidelines, components,
and tools that support
best practices for UI
design
Material Design homepage
Interactive building
blocks for creating a
user interface
implementation
'com.google.android.material:material:<version>'
In values-night/themes.xml:
<style name="AppTheme"
parent="Theme.MaterialComponents.DayNight">
<item name="colorPrimary">@color/orange_200</item>
...
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
This work is licensed under the
Android Development with Kotlin Apache 2 license. 39
Bottom navigation
<LinearLayout …>
...
<com.google.android.material.bottomnavigation.BottomNavigationVi
ew
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:menu="@menu/bottom_navigation_menu" />
</LinearLayout>
This work is licensed under the
Android Development with Kotlin Apache 2 license. 41
Bottom navigation listener
bottomNav.setOnNavigationItemSelectedListener { item ->
when(item.itemId) {
R.id.item1 -> {
// Respond to navigation item 1 click
true
}
R.id.item2 -> {
true
}
else -> false
}
}
<com.google.android.material.floatingactionbutton.FloatingActionButto
n
android:id="@+id/floating_action_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:contentDescription="@string/fab_content_desc"
app:fabSize="normal" <!-- or mini or auto -->
app:srcCompat="@drawable/ic_plus"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
This work is licensed under the
Android Development with Kotlin Apache 2 license. 47
Cards
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView .../>
<TextView .../>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
This work is licensed under the
Android Development with Kotlin Apache 2 license. 49
Localization
Sunflowe Google
r app I/O app