Skip to Content
Android 9 Development Cookbook - Third Edition
book

Android 9 Development Cookbook - Third Edition

by Rick Boyer
October 2018
Intermediate to advanced
464 pages
15h 17m
English
Packt Publishing
Content preview from Android 9 Development Cookbook - Third Edition

How to do it...

We start by adding a new theme to the existing styles.xml file to make our activity look like a dialog. Here are the steps to create the new theme and set the activity to use the new theme:

  1. Since themes are defined in the same resource as styles, open the styles.xml file located in res/values and create a new style. We will create a new style based on the AppTheme already provided, and set windowIsFloating. The XML will be as follows:
<style name="AppTheme.MyDialog"> 
    <item name="android:windowIsFloating">true</item> 
</style> 
  1. Next, set the activity to use this new dialog theme. Open the AndroidManifest.xml file and add a theme attribute to the activity element, as shown:
<activity android:name=".MainActivity" android:theme="@style/AppTheme.MyDialog"> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Android Application Development Cookbook - Second Edition

Android Application Development Cookbook - Second Edition

Rick Boyer, Kyle Mew
Android High Performance Programming

Android High Performance Programming

Enrique López Mañas, Diego Grancini
Android Things Projects

Android Things Projects

Francesco Azzola

Publisher Resources

ISBN: 9781788991216Supplemental Content