Custom Title Bar in Android Preference Screen
<p>I have Android <code>Preference Screen</code> in which I have tried to add custom <code>Title Bar</code> with extra xml. But I am getting <code>Preference Menu</code> on title bar and unable to set <code>marginBottom</code>. Its looking like below.</p>

<p><a href="https://i.stack.imgur.com/wTZjz.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wTZjz.jpg" alt="enter image description here"></a></p>

<p>My <strong>Preference xml</strong> is like below</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" &gt;
    

        
        &lt;Preference
            android:defaultValue=""
            android:key="about"
            android:summary="Know About Us From Here"
            android:title="About" /&gt;
        
        &lt;CheckBoxPreference
            android:key="background"
            android:summary="Show Image with Status as Background"
            android:title="Background Image" /&gt;
        
        &lt;Preference
            android:defaultValue=""
            android:key="more"
            android:summary="Get More Useful Applications By Us"
            android:title="More Application" /&gt;
        
        &lt;Preference
            android:defaultValue=""
            android:key="rate"
            android:summary="Give Us Five Star in Play Store and Support Us"
            android:title="Rate Us" /&gt;
        &lt;Preference
            android:defaultValue=""
            android:key="shayari"
            android:summary="Download Hindi Shayari Application"
            android:title="Shayari App" /&gt;
        
        &lt;Preference
            android:defaultValue=""
            android:key="check"
            android:summary="Download New Quotes Via Click Here"
            android:title="Download New Quotes" /&gt;
       
        &lt;CheckBoxPreference
            android:key="checkauto"
            android:summary="Tick to dont download automatically"
            android:title="Dont download Auto" /&gt;
        
        &lt;Preference
            android:defaultValue=""
            android:key="share"
            android:summary="You can Share This Application to Your Friends"
            android:title="Share Application" /&gt;
        

&lt;/PreferenceScreen&gt;</code></pre>
</div>
</div>
</p>

<p>My <strong>custom Xml</strong> for title is like below</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;

&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                 xmlns:ads="http://schemas.android.com/apk/res-auto"
                 android:layout_height="fill_parent"
                android:layout_width="fill_parent"&gt;
                
    &lt;LinearLayout
        android:id="@+id/titleBar"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="@drawable/title_bar"
        android:layout_alignParentTop="true"
        android:layout_marginBottom="20dp"
        android:orientation="horizontal" &gt;

        &lt;ImageView
            android:id="@+id/iconImg"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_gravity="center"
            android:layout_margin="5dip"
            android:background="@drawable/app_icon" /&gt;

        &lt;ImageView
            android:id="@+id/titleImg"
            android:layout_width="160dp"
            android:layout_height="45dp"
            android:layout_gravity="center"
            android:layout_margin="5dip"
            android:background="@drawable/title" /&gt;

        &lt;RelativeLayout
            android:id="@+id/pagerBtn"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:paddingRight="2dip" &gt;
        &lt;/RelativeLayout&gt;
    &lt;/LinearLayout&gt;

    &lt;ListView android:id="@android:id/list" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"/&gt;

    &lt;com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        ads:adSize="BANNER"
        android:layout_alignParentBottom="true"
        ads:adUnitId="@string/admob_publisher_id"
         /&gt;

&lt;/RelativeLayout&gt;</code></pre>
</div>
</div>
</p>

<p>and finally my Preference Java code is like below</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>public void onCreate(Bundle savedInstanceState) {
  requestWindowFeature(Window.FEATURE_NO_TITLE);
  this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
  super.onCreate(savedInstanceState);
        setContentView(R.layout.config);
        mAdView = (AdView) findViewById(R.id.adView);
  mAdView.loadAd(new AdRequest.Builder().build());

  db = new DAO(this);
  db.open();
  
  
  
  pref = getApplicationContext().getSharedPreferences("com.test.app_prefences.xml",0);
  
  tocheck = pref.getInt("highscoresaved",0);</code></pre>
</div>
</div>
</p>

<p>What I am missing or where should I make changes for make header layout complete ?
Thanks</p>