江苏手机网站建设公司,重庆企业网站seo,手机建网站需要多少钱,最大免费广告发布平台帧布局容器为每个加入其中的组件创建一个空白的区域(称为一帧)#xff0c;所有每个子组件占据一帧#xff0c;这些帧都会根据gravity属性执行自动对齐。FrameLayout的常用XML属性和相关方法XML属性相关方法说 明android:foregroundsetForeground(Drawable)设置该帧布局容器…帧布局容器为每个加入其中的组件创建一个空白的区域(称为一帧)所有每个子组件占据一帧这些帧都会根据gravity属性执行自动对齐。FrameLayout的常用XML属性和相关方法XML属性相关方法说 明android:foregroundsetForeground(Drawable)设置该帧布局容器的前景图像android:foregroundGravitysetForegroundGravity(int)定义绘制前景图像的gravity属性下面的布局界面定义使用FrameLayout布局并向该布局容器中添加了7个TextView这7个TextView的高度完全相同而宽度逐渐减少——这保证最先添加的TextView不会被完全遮挡而且设置了7个TextView的背景色渐变。android:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:orientationverticalandroid:idid/View01android:layout_width210dpandroid:layout_height200dpandroid:background#ff0000/android:idid/View02android:layout_width180dpandroid:layout_height200dpandroid:background#dd0000/android:idid/View03android:layout_width150dpandroid:layout_height200dpandroid:background#bb0000/android:idid/View04android:layout_width120dpandroid:layout_height200dpandroid:background#990000/android:idid/View05android:layout_width90dpandroid:layout_height200dpandroid:background#770000/android:idid/View06android:layout_width60dpandroid:layout_height200dpandroid:background#550000/android:idid/View07android:layout_width30dpandroid:layout_height200dpandroid:background#330000/效果如图颜色渐变.jpg霓虹灯效果如果考虑轮换上面帧布局中的7个TextView的背景色就会看到上面的颜色渐变条不断地变化就像大街上的霓虹灯。private int currentColor 0;//定义一个颜色数组final int[] colors new int[]{R.color.color7,R.color.color6,R.color.color5,R.color.color4,R.color.color3,R.color.color2,R.color.color1};final int[] names new int[]{R.id.View01,R.id.View02,R.id.View03,R.id.View04,R.id.View05,R.id.View06,R.id.View07,};TextView[] views new TextView[7];Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity3);for (int i 0; i 7; i) {views[i] findViewById(names[i]);}SuppressLint(HandlerLeak)final Handler handler new Handler() {Overridepublic void handleMessage(NonNull Message msg) {if (msg.what 0x1122) {for (int i 0; i 7 - currentColor; i) {views[i].setBackgroundResource(colors[i currentColor]);}for (int i 7 - currentColor, j 0; i 7; i, j) {views[i].setBackgroundResource(colors[j]);}}super.handleMessage(msg);}};//定义一个线程周期性地改变currentColor变量值new Timer().schedule(new TimerTask() {Overridepublic void run() {currentColor;if (currentColor 6) {currentColor 0;}Message m new Message();m.what 0x1122;handler.sendMessage(m);}}, 0, 500);}