Adaptive icons are defined using 2 layers and a mask. In Android 7. You must now size your icon layers using the following guidelines:. Note: Animated visual effects are generated by supported launchers. Visual effects may vary from one launcher to another. Caution: A device OEM can specify a mask that may include a radius that is as short as 33 dp along certain points of the shape.
Caution: If you don't update your launcher icon with the necessary layers, the icon doesn't look consistent with other icons that the system UI displays, and doesn't support visual effects.
To add an adaptive icon to an app using XML, begin by updating the android:icon attribute in your app manifest to specify a drawable resource. You can also define an icon drawable resource using the android:roundIcon attribute.
You must only use the android:roundIcon attribute if you require a different icon asset for circular masks, if for example the branding of your logo relies on a circular shape. The following code snippet illustrates both of these attributes:. Next you must create alternative drawable resources in your app for use with Android 8. If you want to apply the same mask and visual effect to your shortcuts as regular adaptive launcher icons, use one of the following techniques:.
For additional information on designing and implementing adaptive icons, read this series of articles by Google designer and developer Nick Butcher:. Content and code samples on this page are subject to the licenses described in the Content License. App Basics. Build your first app. App resources. Resource types. App manifest file. Device compatibility. Multiple APK support. Tablets, large screens, and foldables. Build responsive UIs. Build for foldables. Getting started. Handling data.
User input. Watch Face Studio. Health services. Creating watch faces. Android TV. Build TV Apps. Build TV playback apps. Help users find content on TV. Recommend TV content. Watch Next. Build TV games. Build TV input services. TV Accessibility.
Android for Cars. Build media apps for cars. Build navigation, parking, and charging apps for cars. Android Things. Supported hardware. Advanced setup.
Build apps. Create a Things app. Communicate with wireless devices. Configure devices. Interact with peripherals. Build user-space drivers. Manage devices. Create a build. Push an update. Chrome OS devices. App architecture. Architecture Components. UI layer libraries.
View binding. Data binding library. Lifecycle-aware components. Paging Library. Paging 2. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast what if you could invest in your favorite developer? Who owns this outage? Building intelligent escalation chains for modern SRE.
Featured on Meta. Now live: A fully responsive profile. Reducing the weight of our footer. Visit chat. Linked Related Hot Network Questions. Question feed. Stack Overflow works best with JavaScript enabled. If you see this message, you need to make sure to follow the previous steps.
Note that the Toolbar is added as the first child of the main content view by adding the include tag. Note: if you are using a CoordinatorLayout, it must not lie outside of the DrawerLayout. Setup a handler to respond to click events on the navigation elements and swap out the fragment. This can be put into the activity directly:. The NavigationView also accepts a custom attribute that can reference a layout that provides a header of our layout.
This app:headerLayout inflates the specified layout into the header automatically. This can alternatively be done at runtime with:. If you need to get a reference to the header, you need to use the new getHeaderView method. Note, that you have to check the header count in order to avoid NPE! In order for the hamburger icon to animate to indicate the drawer is being opened and closed, we need to use the ActionBarDrawerToggle class.
Next, we need to make sure we synchronize the state whenever the screen is restored or there is a configuration change i. The ActionBarToggle will perform the same function done previously but adds a bit more checks and allows mouse clicks on the icon to open and close the drawer. See the source code for more context. To have the status bar translucent and have our drawer slide over it, we need to set android:windowTranslucentStatus to true.
Now if you run your app, you should see the navigation drawer and be able to select between your fragments. One improvement made to the design support library For instance, we can create a custom switch like the navigation drawer from Google Play Movies for one of the rows:. The approach is the same as adding ActionView items to the ActionBar. We simply need to define a separate layout such as the following snippet. We then reference this layout using the app:actionLayout attribute.
A title must be provided but can also be set to blank:. You can attach events directly in XML so long as your Activity will implement the method.
0コメント