布局动画 属性初始 android:animateLayoutChanges
2015-08-16 14:02
627 查看
容器控件 android默认没有开启子控件变化的动画,也就是说animateLayoutChanges=false, animateLayoutChanges 属性 强调 必须api>=11 但是我测试了 在API=8上面没有报错,只是没有效果而已 android:animateLayoutChanges="true" 表示开启系统的布局动画
实例:xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:animateLayoutChanges="true" android:layout_height="match_parent"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="add" android:id="@+id/bt_add" /> </LinearLayout>
[/code]
代码:
package com.example.xuan.layoutAnimation; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.LinearLayout; import java.util.Random; public class PlaceHolderFragment2 extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final LinearLayout rootView = (LinearLayout) inflater.inflate(R.layout.fragment_main2, container, false); rootView.findViewById(R.id.bt_add).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Button button = new Button(getActivity()); button.setText("" + new Random().nextInt(100)); rootView.addView(button); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { rootView.removeView(view); } }); } }); return rootView; } }
[/code]
相关文章推荐
- Android:EditText中切换密码的显示与隐藏
- android 5.1 源码编译adb
- Android中自定义RatingBar
- Android 使用android-support-multidex解决Dex超出方法数的限制问题,让你的应用不再爆棚
- Android 基础:surfaceSurface、SurfaceHolder 及 SurfaceHolder.Callback , 范例说明
- Android的所有权限说明
- Android Studio系列教程四--Gradle基础
- Android Context作用
- Android源码分析之ListView
- Android - 电池状态
- Android的ListView分页功能
- qq登陆
- android 相机图库调用以及裁剪
- android学习笔记1
- Android SQLite 简单使用示例
- android-音乐播放器实现及源码下载(四)
- android-音乐播放器实现及源码下载(三)
- android-音乐播放器实现及源码下载(二)
- android-音乐播放器实现及源码下载(一)
- android体系结构以及源代码阅读环境搭建