Skip to content

Instantly share code, notes, and snippets.

@slightfoot
Created May 21, 2013 11:29
Show Gist options
  • Save slightfoot/5619170 to your computer and use it in GitHub Desktop.
Save slightfoot/5619170 to your computer and use it in GitHub Desktop.
Adding some view as the decor to a ViewPager
<?xml version="1.0" encoding="utf-8"?>
<com.example.myapp.adview
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ad_view"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_gravity="bottom|fill_horizontal"
android:background="#000000"
/>
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
ViewPager viewPager = (ViewPager)super.onCreateView(inflater, container, savedInstanceState);
View adView = inflater.inflate(R.layout.decor_adview, viewPager, false);
((ViewPager.LayoutParams)adView.getLayoutParams()).isDecor = true;
viewPager.addView(adView);
return viewPager;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment