Android整个布局缩放
来源:互联网 发布:个股融资融券数据查询 编辑:程序博客网 时间:2024/06/02 04:48
效果图
在整个界面的跟布局设置一个ID,在Activity中获取这个控件
<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/content" android:background="#F00" tools:context="com.xiaoge.scaledemo.MainActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" android:textSize="36sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent"/></android.support.constraint.ConstraintLayout>
Activity中的代码
public class MainActivity extends AppCompatActivity { private ConstraintLayout content; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initView(); scaleWindow(); } private void initView() { content = (ConstraintLayout) findViewById(R.id.content); } private void scaleWindow() { /** 设置缩放动画 */ final ScaleAnimation animation = new ScaleAnimation(1f, 0.9f, 1f, 0.9f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);// 从相对于自身0.5倍的位置开始缩放,也就是从控件的位置缩放 animation.setDuration(2000);//设置动画持续时间 /** 常用方法 */ //animation.setRepeatCount(int repeatCount);//设置重复次数 animation.setFillAfter(true);//动画执行完后是否停留在执行完的状态 //animation.setStartOffset(long startOffset);//执行前的等待时间 content.setAnimation(animation); /** 开始动画 */ animation.startNow(); }}
1 0
- Android整个布局缩放
- android的TableLayout布局界面元素填满整个屏幕
- Android软键盘顶起整个布局的调整
- android 将整个布局设置为不可点击状态
- Android自定义View之布局(layout)缩放
- 页面缩放布局控制
- css整体缩放布局
- Flex-缩放自适应布局
- 整个App都有侧拉效果 ---布局
- Android在线切换主题(换肤),支持直接替换整个布局
- Android 自定义ViewGroup实现整个Item布局竖直跑马灯效果
- android中点击输入框时整个布局被上移的解决办法
- android 软键盘中的“下一步“”把整个布局都顶上去
- android 解决ScrollView中的子布局不能够填充整个ScrollView
- android 改变listview的item宽高和让整个item布局居中显示的方式
- android关闭整个应用程序
- android退出整个程序
- android sensors整个流程
- 宏定义与宏展开-转子论坛帖子
- @RequestParam和不用的区别以及和 @PathVariable 的区别,简单易懂
- Weex入门与进阶指南
- 将二叉树拆成链表
- 文件下载
- Android整个布局缩放
- PCIe 接口 引脚定义 一览表
- Linux防火墙iptables的启动与关闭
- Linux运维工程师必学必备的8项IT技能
- 关于Android面试那些事
- jquery $.proxy使用
- ubuntu安装caffe以及遇到的问题
- 欢迎使用CSDN-markdown编辑器
- Erlang服务端与微信登录和微信支付接口的交互