framelayout

安卓实现图片闪烁效果动画

穿精又带淫゛_ 提交于 2019-11-27 05:05:32
   大家在使用APP的时候,有的APP在点击语音搜索界面后,会出现一个小话筒,小话筒会类似雷达似得在闪烁,表示正在倾听你说话的内容(这个大家可以参照微软的必应APP),那么问题来了,这种动画效果是如何实现的呢?其实实现这种动画效果有很多种方法,最常见的是两种:第一种就是插入n张图片进行切换已达到如此目的,第二种就是通过改变一张图片的透明度来达到闪烁的效果。下面就分别讲一下通过这两种方法如何实现。 第一种:通过n张图片之间切换实现动画效果    这种方法的原理很简单,利用handler的延时机制在子线程中完成图片切换,再在主线程展示。   1、首先我们要先写一个线程池,在使用的时候方便调用。 1 package com.jereh.musicapplication.threadpool; 2 3 import java.util.concurrent.ExecutorService; 4 import java.util.concurrent.Executors; 5 import java.util.concurrent.ScheduledExecutorService; 6 7 /** 8 * Created by zhangdi on 2016/9/1. 9 * 这是一个线程池的工具类,在用到线程的时候可以直接类名加方法名使用 10 */ 11 public class

Android之FrameLayout(帧布局)

旧时模样 提交于 2019-11-27 01:55:47
重点 FrameLayout(帧布局)可以说是最简单的布局了,我们添加控件时会默认把控件放到屏幕的左上角,后续添加的会把上一个覆盖,我们可以通过layout_gravity来移动控件。 属性 android:foreground:设置改帧布局容器的 前景图像 android:foregroundGravity:设置前景图像显示的位置 那么前景图像是什么呢?和字面意思一样,是在布局最上方不会被覆盖的图像。 布局代码: <?xml version="1.0" encoding="utf-8"?> < FrameLayout xmlns:android = "http://schemas.android.com/apk/res/android" android:layout_width = "match_parent" android:layout_height = "match_parent" > < TextView android:layout_width = "200dp" android:layout_height = "200dp" android:background = "#FF0000" /> < TextView android:layout_width = "150dp" android:layout_height = "150dp" android

Android布局之FrameLayout

。_饼干妹妹 提交于 2019-11-27 01:55:37
FrameLayout帧布局也叫层布局。从屏幕左上角按照层次叠堆方式布局,层层覆盖。 应用场景:地图布局 普通功能软件设计应用场景不多 效果图: <?xml version="1.0" encoding="utf-8"?> < FrameLayout xmlns:android = "http://schemas.android.com/apk/res/android" android:layout_width = "match_parent" android:layout_height = "match_parent" > < TextView android:layout_width = "400dp" android:layout_height = "400dp" android:layout_gravity = "center" android:background = "@android:color/holo_red_dark" /> < TextView android:layout_width = "300dp" android:layout_height = "300dp" android:layout_gravity = "center" android:background = "@android:color/holo_blue_light" /> <

java 代码 添加控件 修改位置

只谈情不闲聊 提交于 2019-11-26 12:50:16
Button button = new Button(this); FrameLayout frameLayout = getWindow().getDecorView().findViewById(android.R.id.content); frameLayout.addView(button); FrameLayout.LayoutParams layout= (FrameLayout.LayoutParams) button.getLayoutParams(); layout.setMargins(100,120,0,0); layout.width = 200; layout.height = 200; button.setLayoutParams(layout); 添加一个Button,修改其高度、宽度、以及位置。 来源: https://www.cnblogs.com/zhaozilongcjiajia/p/11320880.html