AND-801 practice question 2 of 10
Which of the below choices is the best answer to fill the empty space in the following sentence? If you want to give all text widgets in an app the…
Full set: 45 questionsIn Android development, styles and themes are defined as XML resources in a dedicated file within the res/values/ directory. The conventional filename for this purpose is styles.xml (or themes.xml). Defining a style in this central location allows it to be reused across multiple layouts and views throughout the application, ensuring a consistent look and feel. This practice separates the UI's design (style) from its structure (layout), which is a fundamental principle of robust Android app architecture. The style is then applied to a View in a layout file using the style attribute, for example, style="@style/stylename".
A. AndroidManifest.xml file: This file is used to declare the application's components, permissions, and other essential metadata, not for defining UI style resources.
B. activitymain.xml file: This is a layout file that defines the structure of a user interface for a specific activity. It is not the standard location for defining app-wide, reusable styles.
D. MainActivity.java or MainActivity.kt file: These are source code files for implementing application logic. UI styles are defined declaratively in XML resources, not programmatically within Java or Kotlin code.
1. Official Android Developer Documentation: "A style is defined in an XML resource that is separate from the XML that specifies the layout. This XML file resides in your project's res/values/ directory... The name of the XML file is arbitrary, but it is conventionally named styles.xml."
Source: Google LLC. (2023). Styles and themes. Android Developers. Retrieved from https://developer.android.com/guide/topics/ui/look-and-feel/themes#DefiningStyles, Section: "Defining styles".
2. University Courseware (related material): In materials for teaching Android development, the standard practice is emphasized. For example, in the "Developing Android Apps with Kotlin" course, it is stated that styles are resources defined in XML.
Source: Google. (2022). Use themes and styles. Android Basics in Kotlin. Retrieved from https://developer.android.com/codelabs/android-basics-kotlin-affirmations-app-polish#3, Step 3: "Create a theme and styles". This codelab, used in educational settings, directs the user to create and modify styles within themes.xml (a file analogous to styles.xml) in the res/values directory.
3. Peer-Reviewed Academic Publication (related context): Research on Android development practices highlights the importance of resource externalization for maintainability. Styles are a key type of externalized resource.
Source: Linares-Vásquez, M., Bavota, G., & Poshyvanyk, D. (2014). An empirical study on the quality of android applications. Proceedings of the 11th Working Conference on Mining Software Repositories, 2-11. https://doi.org/10.1145/2597073.2597092. The paper discusses the analysis of Android resources (res/ directory), which implicitly supports the standard practice of separating concerns, such as defining styles in res/values/.
Keep practicing
Take the free AND-801 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other AND-801 practice questions
- Question 1Android SDK platform is a set of libraries and APIs that provide necessary classes, metho…
- Question 5Fill in the blank space in the following sentence with the correct choice: The...........…
- Question 7In Android Studio 3.0 and higher, a checkbox is available to drag-and-drop from the palet…
- Question 9Assume you were given the code of an Android app that include a Google Map. When you chec…
