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 AdView
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 AdView
) to fragment_setting_detail.xml
<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" >
<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" >
</com.google.android.gms.ads.AdView>
</fragment>
I think this is not the correct way but the only one that works right now. But the AdView
is displayed at the top of the screen and i have no idea on how to position it because in Fragments
most parameters arent allowed to use. I even tried to wrap it in a LinearLayout
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 Fragments
(using the sample so i understand)? Many thx in advance