I’m adding AdMob to my application. Apparently I need to add the following layout snippet to each one of my layouts:
<LinearLayout
android:id="@+id/linearLayout"
android:orientation="vertical"
android:layout_below="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
However, I’d rather add the above snippet dynamically, instead of copy-pasting it into each layout.
What I am having trouble with is translating the following snippet:
android:layout_below="@+id/button2"
into Java code.
You have two options (at least):
android:layout_below="@+id/button2"and add this property on code, like says on this question:How to lay out Views in RelativeLayout programmatically?
android:layout_below="@+id/button2". Then in each layout that you want to use this, use the include element: http://developer.android.com/training/improving-layouts/reusing-layouts.htmlHope it helps.