在tabhost中实现向上和向下的动画

 <RelativeLayout android:id="@+id/d_tab" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_width="fill_parent">

    <RelativeLayout android:id="@+id/tabWigth" android:layout_alignParentRight="true" android:layout_width="fill_parent" android:layout_height="wrap_content">

    <Button android:id="@+id/btn_tab_one" android:text="全部" android:layout_width="wrap_content" android:layout_height="wrap_content"/>

    <Button android:id="@+id/btn_tab_two" android:text="只看有内容的" android:layout_toRightOf="@id/btn_tab_one" android:layout_width="wrap_content" android:layout_height="wrap_content"/>

    <Button android:id="@+id/btn_tab_three" android:layout_toRightOf="@id/btn_tab_two" android:layout_width="wrap_content" android:layout_height="wrap_content"/>

    </RelativeLayout>

    <RelativeLayout android:id="@+id/context" android:layout_below="@id/tabWigth" android:background="@drawable/bg" android:layout_width="fill_parent" android:layout_height="wrap_content">

    <ListView android:id="@+id/list_tab_one" android:layout_below="@id/btn_tab_one" android:headerDividersEnabled="true" android:divider="#414141" android:dividerHeight="1dip" android:background="@drawable/backgroup"

android:fastScrollEnabled="true" android:cacheColorHint="#00000000" android:focusable="true" android:layout_width="fill_parent" android:layout_height="fill_parent"></ListView>

    <ListView android:id="@+id/list_tab_two" android:layout_below="@id/btn_tab_two" android:headerDividersEnabled="true" android:divider="#414141" android:dividerHeight="1dip" android:background="@drawable/backgroup"

android:fastScrollEnabled="true" android:cacheColorHint="#00000000" android:focusable="true" android:layout_width="fill_parent" android:layout_height="fill_parent"></ListView>

    </RelativeLayout>

</RelativeLayout>

if(!flag){

btns[2].setBackgroundDrawable(mClient.getResources().getDrawable(R.drawable.top_btn));

//layout.startAnimation(animationUp);

int[] location2 = new int[2];

layout.getLocationOnScreen(location2);

layout.setLayoutParams(lp1);

int[] location = new int[2];

layout.getLocationOnScreen(location);

flag = true;

}else{

btns[2].setBackgroundDrawable(mClient.getResources().getDrawable(R.drawable.top_btn1));

//layout.startAnimation(animationDwon);

layout.setLayoutParams(lp2);

flag = false;

}

layout = (RelativeLayout) rootView.findViewById(R.id.d_tab);

   lp2 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);

   lp1 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);

   lp1.setMargins(0, layout.getTop()+100, 0, 0);

   lp2.addRule(RelativeLayout.BELOW, R.id.relative);

   layout.setLayoutParams(lp2);

posted on 2011-08-17 12:15  jsonjack  阅读(529)  评论(0)    收藏  举报

导航