Created
May 21, 2013 11:29
-
-
Save slightfoot/5619170 to your computer and use it in GitHub Desktop.
Adding some view as the decor to a ViewPager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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" | |
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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