So, the Toolbar sample modules use that base theme instead: There is another base theme,, which skips the theme-supplied action bar, leaving it up to us. The theme has no way of knowing this, and so by default, we would wind up with two app bars, stacked on top of each other: We have our own Toolbar that we want to show instead. The problem is that we do not want an action bar. As the name suggests, this adds an action bar to the top of the activity, with an eye towards it having a dark color, so text will be shown in white for a good contrast. The theme used by prior sample projects in this book was based on. We will explore the app:theme attribute more in the next section. android:background allows you to specify the background color, and here we defer to the theme and use whatever we have set there as colorPrimary ( ?attr/colorPrimary). A simple Toolbar can use wrap_content for the height, and it will be sized appropriately for toolbar buttons and such. The Toolbar has attributes that mostly set up the size and position. So, whereas the ViewModel sample had 8dp of padding in the ConstraintLayout, this sample moves that padding to the RecyclerView, so the Toolbar is not inset from the edges. Usually, the app bar is set to be flush with the status bar and the sides of the screen. Toolbar/src/main/res/layout/activity_main.xml)
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |