2012-11-21 34 views
2

我试图找到类似的问题,但不能。动画的RelativeLayout大小问题

我建立基于片段的应用程序使用支持库。以现代“Google/Facebook”风格设计的用户界面(全屏内容页面+滑动菜单)。下面是主要布局文件:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" > 

<FrameLayout 
    android:id="@+id/mainmenu_fragment" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:background="@color/mainmenu_bg" > 
</FrameLayout> 

<LinearLayout 
    android:id="@+id/contentwrapper" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_toRightOf="@id/mainmenu_fragment" 
    android:background="@android:color/white" 
    android:orientation="vertical" > 

    <fragment 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     class="com.pleazzme.Topline" 
     android:tag="Topline" /> 

    <FrameLayout 
     android:id="@+id/main_categoryline_wrap" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 
    </FrameLayout> 

    <FrameLayout 
     android:id="@+id/main_selectorline_wrap" 
     android:layout_width="match_parent" 
     android:layout_height="50dp" > 
    </FrameLayout> 
</LinearLayout> 

<ImageButton 
    android:id="@+id/main_btn_wallet" 
    android:contentDescription="@string/text_btn_wallet" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:adjustViewBounds="true" 
    android:background="@android:color/transparent" 
    android:src="@drawable/wallet" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentBottom="true" 
    android:onClick="showWallet" /> 

</RelativeLayout> 

这是片段的一种布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/topline_wrapper" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:background="@drawable/topline_tilebg" > 

<ImageView 
    android:id="@+id/topline_title" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:adjustViewBounds="true" 
    android:layout_centerHorizontal="true" 
    android:contentDescription="@string/text_topline_title" 
    android:paddingBottom="10dp" 
    android:paddingLeft="5dp" 
    android:paddingRight="5dp" 
    android:paddingTop="10dp" 
    android:src="@drawable/pleazzme_title" /> 

<Button 
    android:id="@+id/counter_button" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerVertical="true" 
    android:layout_toRightOf="@id/topline_title" 
    android:background="@drawable/topline_newscounter" 
    android:focusable="false" 
    android:focusableInTouchMode="false" 
    android:textColor="@android:color/white" 
    android:visibility="gone" /> 

<Button 
    android:id="@+id/topline_back_button" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerVertical="true" 
    android:background="@drawable/back_but" 
    android:contentDescription="@string/text_back_button" 
    android:focusable="false" 
    android:focusableInTouchMode="false" 
    android:onClick="onBackTrigger" 
    android:text="@string/btn_back" 
    android:textColor="@color/android:white" 
    android:visibility="gone" /> 

<ImageButton 
    android:id="@+id/topline_mainmenu_button" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerVertical="true" 
    android:layout_margin="5dip" 
    android:layout_toRightOf="@id/topline_back_button" 
    android:background="@drawable/sq_but_bg" 
    android:contentDescription="@string/text_mainmenu_button" 
    android:focusable="false" 
    android:focusableInTouchMode="false" 
    android:onClick="onMainmenuTrigger" 
    android:src="@drawable/ico_list" /> 

<ImageButton 
    android:id="@+id/topline_map_button" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_centerVertical="true" 
    android:layout_margin="5dip" 
    android:background="@drawable/sq_but_bg" 
    android:contentDescription="@string/text_map_button" 
    android:focusable="false" 
    android:focusableInTouchMode="false" 
    android:onClick="onMapTrigger" 
    android:src="@drawable/ico_mark" /> 

</RelativeLayout> 

活动onMapTrigger方法:

public void onMainmenuTrigger(View v) { 
    FragmentTransaction ft = fm.beginTransaction(); 
    ft.setCustomAnimations(R.anim.left_to_right, R.anim.right_to_left); 

    if (mml.isHidden()) { 
     mml.clearSearch(); 
     ft.show(mml); 
    } else { 
     ft.hide(mml); 
    } 
    ft.commit(); 
} 

显示动画:

<set xmlns:android="http://schemas.android.com/apk/res/android" > 

<translate 
    android:duration="500" 
    android:fromXDelta="-100%p" 
    android:toXDelta="0" /> 

</set> 

当显示菜单时,visib le topline按钮重叠。 有人可以告诉我,这种情况有什么不对?

回答

0

我发现解决这个问题的唯一方法是使用NineOldAndroids lib重构我的动画。他们对sdk < 11有一些问题,但它的工作。