Android LevelDrawable模拟开灯灭灯的场景
来源:互联网 发布:win10 ssd 磁盘优化 编辑:程序博客网 时间:2024/04/28 03:14
模拟非诚勿扰灭灯场景 请大家一起来灭灯!
首先第一步下载资源,没有的小伙伴我这里提供啦
然后在Drawable目录创建一个level.xml
<?xml version="1.0" encoding="utf-8"?>
<level-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="@drawable/off"
android:minLevel="6"
android:maxLevel="10"></item>
<item
android:drawable="@drawable/on"
android:minLevel="12"
android:maxLevel="20"></item>
</level-list>
然后创建布局文件activity_level
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/iv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/level" />
<Button
android:id="@+id/btn_on"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="30dp"
android:onClick="on"
android:text="开灯" />
<Button
android:id="@+id/btn_off"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="30dp"
android:onClick="off"
android:text="关灯" />
</LinearLayout>
LevelActivity
package com.android.xiong.gridlayoutTest;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
public class LevelActivity extends Activity {
private ImageView iv;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_level);
iv=(ImageView) findViewById(R.id.iv);
iv.setImageLevel(10);
}
public void on(View v){
iv.setImageLevel(15);
//开灯
}
public void off(View v){
iv.setImageLevel(10);
//关灯
}
}
效果如下
- Android LevelDrawable模拟开灯灭灯的场景
- Android 同一个ImageView显示不同的图片(LevelDrawable)
- android 模拟因为内存使用不足,杀死应用的场景
- 开灯问题 简单模拟法
- 同一个ImageView显示不同的图片(LevelDrawable)
- 同一个ImageView显示不同的图片(LevelDrawable)
- 同一个ImageView显示不同的图片(LevelDrawable)
- 关于亮灯,1,2,3倍数开灯和灭灯问题的Java代码实现
- 开灯问题的求解!
- 模拟RI锁定导致阻塞的场景
- 线程的join()方法 模拟做饭场景
- 【C】模拟三次密码输入的场景
- 模拟输入密码登陆时的场景
- 模拟三次密码输入的场景
- 模拟三次密码输入的场景
- 模拟三次密码输入的场景
- 汇编---智慧交通场景的模拟实现
- n个灯,k个人的开灯问题
- #poj 2286 入门级IDA*
- android之Okhttp连接https添加自产证书
- JS获取字符串实际长度!
- 动态规划理论
- 禁用cookie后,使用session
- Android LevelDrawable模拟开灯灭灯的场景
- SSH远程连接故障
- ionic开发webApp---百度定位
- QThreadPool的简单使用
- C# .net MVC 微信红包(服务号发送红包)
- NSA方程式组织被黑事件跟踪:拍卖、合法性、俄罗斯黑客阴谋论......
- javaweb获取数据库连接
- 安卓自定义 View 进阶: 图片文字
- 关于动态加载布局的那些事(笔记)