title: Adding view to xml fragment in Android
body: <p>I just started with android development and run into a problem i cannot find any information for. I created a project using the two-pane template. I was able to add a <code>AdView</code> and many other views to my app while in two-pane mode (activity_setting_twopane.xml). Where i struggle is on how to add a view (any) to the other layout for smaller displays (activity_setting_detail.xml, activity_setting_list.xml or fragment_setting_detail.xml?). I was able to add a view (an <code>AdView</code>) to fragment_setting_detail.xml</p>
  
  <pre><code>&lt;fragment xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      xmlns:ads="http://schemas.android.com/apk/res-auto"
      android:id="@+id/setting_list"
      android:name="com.test.firstapp.SettingListFragment"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_marginLeft="16dp"
      android:layout_marginRight="16dp"
      tools:context=".SettingListActivity" 
      tools:layout="@android:layout/list_content" &gt;
  
      &lt;com.google.android.gms.ads.AdView
          android:id="@+id/adView"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          ads:adSize="BANNER"
          ads:adUnitId="xxxxxxxxxxxxxxxxx" &gt;
      &lt;/com.google.android.gms.ads.AdView&gt;
  
  &lt;/fragment&gt;
  </code></pre>
  
  <p>I think this is not the correct way but the only one that works right now. But the <code>AdView</code> is displayed at the top of the screen and i have no idea on how to position it because in <code>Fragments</code> most parameters arent allowed to use. I even tried to wrap it in a <code>LinearLayout</code> but then the sample project crashes where i want to add the view to the layout in code. What is the correct way to add any views to xml based <code>Fragments</code> (using the sample so i understand)? Many thx in advance</p>