UI_动画

本文详细介绍了一种在Android中使用XML定义复杂视图动画的方法,包括透明度、旋转、缩放和位移等效果的组合,实现了视图从无到有、旋转放大并下移的动态展示过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

		image = (ImageView) findViewById(R.id.image1);
		//加载动画
		Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.set);
		image.startAnimation(animation);





    //R.anim.set
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
   android:duration="5000"
   android:fillAfter="true"
    >
   <!--  //开始 -->
  	<alpha
  	    android:fromAlpha="0"
  	    android:toAlpha="1"
  	    />
  	
    <!-- //旋转 -->
    	<rotate
    	    android:fromDegrees="0"
    	    android:toDegrees="720"
    	    android:pivotX="50%"
    	    android:pivotY="50%"
    	    ></rotate>
     
	<!-- 缩放-->
	<scale
	    android:fromXScale="0"
	    android:toXScale="5.0"
	    android:fromYScale="0"
	    android:toYScale="5.0"
	    android:pivotX="50%"
    	android:pivotY="50%"
	    />	
	<!-- //下移	 -->
	<translate
	    android:fromXDelta="0%p"
		android:toXDelta="0%p"
	    android:fromYDelta="-1%p"
		android:toYDelta="50%p"
	    ></translate>
	
</set>

 

// This file was generated by SquareLine Studio // SquareLine Studio version: SquareLine Studio 1.4.2 // LVGL version: 9.1.0 // Project name: SquareLine_Project #include "../ui.h" void ui_Screen3_screen_init(void) { ui_Screen3 = lv_obj_create(NULL); lv_obj_remove_flag(ui_Screen3, LV_OBJ_FLAG_SCROLLABLE); /// Flags lv_obj_set_style_bg_image_src(ui_Screen3, &ui_img_bg_png, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_color(ui_Screen3, lv_color_hex(0x00FF00), LV_PART_SCROLLBAR | LV_STATE_DEFAULT); lv_obj_set_style_bg_opa(ui_Screen3, 255, LV_PART_SCROLLBAR | LV_STATE_DEFAULT); lv_obj_set_style_bg_image_src(ui_Screen3, &ui_img_game_png, LV_PART_SCROLLBAR | LV_STATE_DEFAULT); ui_Button2 = lv_button_create(ui_Screen3); lv_obj_set_width(ui_Button2, 100); lv_obj_set_height(ui_Button2, 50); lv_obj_set_x(ui_Button2, -456); lv_obj_set_y(ui_Button2, -277); lv_obj_set_align(ui_Button2, LV_ALIGN_CENTER); lv_obj_add_flag(ui_Button2, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags lv_obj_remove_flag(ui_Button2, LV_OBJ_FLAG_SCROLLABLE); /// Flags lv_obj_set_style_bg_color(ui_Button2, lv_color_hex(0xFF8200), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_opa(ui_Button2, 100, LV_PART_MAIN | LV_STATE_DEFAULT); ui_Label3 = lv_label_create(ui_Screen3); lv_obj_set_width(ui_Label3, LV_SIZE_CONTENT); /// 1 lv_obj_set_height(ui_Label3, LV_SIZE_CONTENT); /// 1 lv_obj_set_x(ui_Label3, -458); lv_obj_set_y(ui_Label3, -277); lv_obj_set_align(ui_Label3, LV_ALIGN_CENTER); lv_label_set_text(ui_Label3, "退出"); lv_obj_set_style_text_font(ui_Label3, &ui_font_chinese38, LV_PART_MAIN | LV_STATE_DEFAULT); // 分数标签 ui_ScoreLabel = lv_label_create(ui_Screen3); lv_label_set_text(ui_ScoreLabel, "Score: 0"); lv_obj_align(ui_ScoreLabel, LV_ALIGN_TOP_RIGHT, -10, 10); lv_obj_set_style_text_font(ui_ScoreLabel, &lv_font_montserrat_28, LV_PART_MAIN); // 28像素字体大小 lv_obj_set_style_text_color(ui_ScoreLabel, lv_color_hex(0xFFFFFF), LV_PART_MAIN); // 白色字体 lv_obj_set_style_text_opa(ui_ScoreLabel, LV_OPA_COVER, LV_PART_MAIN); // 完全不透明 lv_obj_add_event_cb(ui_Button2, ui_event_Button2, LV_EVENT_ALL, NULL); } 在此背景下调用游戏函数实现切水果游戏,结合现有代码
最新发布
08-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值