Custom Action Bar Layoutįollowing is the view layout that will be set to the ActionBar from our MainActivity. Note that we will be using AppCompatActivity since it provides maximum compatibility with pre-3.0 Android versions. The contentInsetStart and contentInsetEnd are the padding values. Hence we’ll use the CustomTheme style in this project. Following is the xml layout for that: styles.xml įrom the above snippet if we use AppTheme style for our activity, it will throw a null pointer exception as it explicitly specifies the NoActionBar theme. To customise an ActionBar first we need to configure the Theme in the res/values/styles.xml and set the theme for the respective activity class in the AndroidManifest.xml.
We assume that you have a basic understanding of the ActionBar component discussed in this tutorial. In this tutorial we will create an app that consists of Android Custom Action Bar with a custom layout.