title: How do I add 3 dot overflow menu on custom action bar for Oreo?
body: <p>I want to add <strong>overflow menu</strong> on my custom action bar. I know, I can add new settings activity but that's too confusing, and I wanted to know the exact code to add those.</p>
  
  <p>I have seen few posts, but it was limited to older SDKs. As I am using custom layout for my action bar. Please help me so that code could work for Android 8.0 and for sdk's lower than that. </p>
  
  <p>My code is as follows:</p>
  
  <p><strong>HomescreenActivity.java</strong> :-</p>
  
  <pre><code>@Override
      protected void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_homescreen);
  
          getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
          getSupportActionBar().setCustomView(R.layout.abs_layout);
  
     }
  </code></pre>
  
  <p><strong>activity_homescreen.xml</strong> :-</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:background="@drawable/paper_planes_color_bg"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".HomescreenActivity"&gt;
  
     &lt;android.support.v7.widget.RecyclerView
         android:layout_marginTop="15dp"
         android:id="@+id/recy_category"
         android:layout_width="match_parent"
         android:layout_height="match_parent"&gt;
     &lt;/android.support.v7.widget.RecyclerView&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>abs_layout.xml</strong> :-</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical"&gt;
  
      &lt;android.support.v7.widget.AppCompatTextView
          android:id="@+id/tvTitle"
          style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center"
          android:gravity="center"
          android:textColor="#FFFFFF" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>