我希望Animation在View将其可见性设置为时进行制作GONE.View应该"崩溃" ,而不仅仅是消失.我尝试了这个ScaleAnimation但是然后View是崩溃,但布局只会在Animation停止(或开始)之后(或之前)调整它的空间.
我如何制作,Animation以便在制作动画时,较低的Views将直接保留在内容之下,而不是有空格?
好吧,我正在尝试做一个合适的下滑动画.向下滑动的视图应该将所有视图推向一个平滑的运动,并且当它向上滑动时,所有视图应该在一个平滑的运动中跟随.
我试过的:在代码中:
LinearLayout lin = (LinearLayout)findViewById(R.id.user_list_container);
setLayoutAnimSlidedownfromtop(lin, this);
lin.addView(getLayoutInflater().inflate(R.layout.user_panel,null),0);
Run Code Online (Sandbox Code Playgroud)
和:
public static void setLayoutAnimSlidedownfromtop(ViewGroup panel, Context ctx) {
AnimationSet set = new AnimationSet(true);
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(100);
set.addAnimation(animation);
animation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f
);
animation.setDuration(500);
set.addAnimation(animation);
LayoutAnimationController controller =
new LayoutAnimationController(set, 0.25f);
panel.setLayoutAnimation(controller);
}
Run Code Online (Sandbox Code Playgroud)
我的user_panel.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="vertical" >
<ImageView
android:layout_alignParentLeft="true"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/icon" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
主要xml的顶部:
<LinearLayout
android:id="@+id/user_list_container"
android:layout_alignParentTop="true"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<LinearLayout …Run Code Online (Sandbox Code Playgroud) Android中有一个可扩展的listview小部件,但它似乎没有使用材料设计样式/规格进行更新.有什么我可以做的,以便它具有材料设计风格和动画?
android android-layout android-support-library android-design-library
我正在尝试将动画添加到我的应用程序中,该动画将隐藏或在单击时显示菜单.基本上类似于Pulse新闻阅读器的文章观点.我能够为菜单容器设置动画.但是,菜单不会在主容器为菜单持有者创建空间的同时向下滑动.我想知道如何解决这个问题.
这是我的动画代码:
if(homeTabBar.getVisibility() == View.GONE){
homeTabBar.setVisibility(View.VISIBLE);
final Animation tabBlockHolderAnimation = AnimationUtils.loadAnimation(ArticleActivity.this, R.anim.tab_down);
tabBlockHolderAnimation.setFillAfter(true);
homeTabBar.startAnimation(tabBlockHolderAnimation);
}else{
final Animation tabBlockHolderAnimation = AnimationUtils.loadAnimation(ArticleActivity.this, R.anim.tab_up);
tabBlockHolderAnimation.setAnimationListener(new AnimationListener(){
@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
homeTabBar.setVisibility(View.GONE);
}
});
tabBlockHolderAnimation.setFillAfter(true);
homeTabBar.startAnimation(tabBlockHolderAnimation);
Run Code Online (Sandbox Code Playgroud)