I wanted to implement a sliding menu bar like the Facebook app and I used the following github example to implement it.
I have an add Layout in all of my apps screens. My problem is as follows:
- I open the app.
- I click on the icon that opens the menu
- If app loads during the time I have opened my menu, the menu automatically closes.
- If you click on the icon that opens the menu, the menu dances.
- This only happens if the add loads when the menu is open.
Here is my typical layout file
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" style="@style/Fill" > <FrameLayout android:id="@+id/FL_home" style="@style/Fill" android:layout_above="@id/adView" > <include layout="@layout/app_com_menu" /> <LinearLayout android:id="@+id/LL_app" style="@style/Fill.RL" android:orientation="vertical" > <include layout="@layout/app_com_title" /> <ListView style="@style/FillWrap.List" /> <include layout="@layout/network_error" /> <include layout="@layout/error_no_live"/> </LinearLayout> </FrameLayout> <include layout="@layout/ad_layout" />
My ad_layout file is as follows:
<?xml version="1.0" encoding="utf-8"?> <com.google.ads.AdView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" android:id="@+id/adView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" ads:adSize="BANNER" ads:adUnitId="xxxxxxxxxxxx" ads:loadAdOnCreate="true" android:visibility="gone" />
And this is the main logic of the sliding drawer
class AppMenuListener implements OnClickListener { public void onClick(View v) { doAnimation(); } } class AppMenuCloseListener implements OnClickListener { public void onClick(View v) { if (menuOut) { doAnimation(); } } } private void doAnimation() { AppBase me = AppBase.this; Animation animation = null; int width = appPage.getMeasuredWidth(); int height = appPage.getMeasuredHeight(); int left = (int) (appPage.getMeasuredWidth() * 0.67); if (menuOut) { if (appMenu.getVisibility() == View.VISIBLE) { animation = new TranslateAnimation(0, -left, 0, 0); animation.setDuration(300); animParams.set(0, 0, width, height); } } else { if (appMenu.getVisibility() == View.INVISIBLE) { animation = new TranslateAnimation(0, left, 0, 0); appMenu.setVisibility(View.VISIBLE); animParams.set(left, 0, left + width, height); animation.setDuration(400); } } animation.setAnimationListener(me); animation.setFillEnabled(true); appPage.startAnimation(animation); } public void onAnimationEnd(Animation animation) { menuOut = !menuOut; if (!menuOut) { appMenu.setVisibility(View.INVISIBLE); } appPage.layout(animParams.left, animParams.top, animParams.right, animParams.bottom); } public void onAnimationRepeat(Animation animation) { } public void onAnimationStart(Animation animation) { } static class AnimParams { int left, right, top, bottom; void set(int left, int top, int right, int bottom) { this.left = left; this.top = top; this.right = right; this.bottom = bottom; } }
I tried using an adListener and stopping ads from loading if menu is out but I didn't have much luck there.
Can someone suggest me what I can do different?
stop sopa justified southland sopa blackout protect ip act jim caldwell internet blackout
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.