`
mmdev
  • 浏览: 12930310 次
  • 性别: Icon_minigender_1
  • 来自: 大连
文章分类
社区版块
存档分类
最新评论

android level-list的使用

 
阅读更多

在/drawable下建立一个level-list.xml,内容如下:

<level-listxmlns:android="http://schemas.android.com/apk/res/android">

<itemandroid:maxLevel="0"android:drawable="@drawable/hotseat_phone_focused"/>

<itemandroid:maxLevel="1"android:drawable="@drawable/hotseat_phone_normal"/>

<itemandroid:maxLevel="2"android:drawable="@drawable/hotseat_phone_pressed"/>

</level-list>

在/layout/下的xml文件中添加一个ImageView

<ImageViewandroid:id="@+id/image"android:src="@drawable/list_src"

android:layout_width="wrap_content"android:layout_height="wrap_content"

/>

最后在.java中对该ImageViewclick事件进行监听

mImageView=(ImageView)findViewById(R.id.image);

mImageView.setOnClickListener(newOnClickListener(){

publicvoidonClick(Viewv){

//TODOAuto-generatedmethodstub

intnCnt=1;

mImageView.getDrawable().setLevel(2);

}

});

这样就能实现显示不同的image了。

分享到:
评论

相关推荐

    Android LevelList 开发使用实例

    大家对android系统电池状态改变的显示已经很熟悉了,但它是如何实现的呢?它是利用了什么技术呢?也许你有你自己的实现方式,但android系统是利用LevelList来实现的。你知道么?

    Android代码-Android-Timeline-View

    PS: Please let me know if you are using this library in your app to list here. email: ark.akshaykale@gmail.com) Install Add following to application level build.gradle file dependencies { //... ...

    Android代码-RollingLayout

    [SDK](https://img.shields.io/badge/API-12+-green.svg?style=flat)](https://android-arsenal.com/api?level=11) Demo &gt;Provide four direction rolling mode. Features [x] Provide four direction for rolling...

    LevelListDrawable 使用及动画demo

    学习levellistdrawable 的时候看的写了个小demo,又不懂的地方大家可以留言哈。一起进步嘛这个东西上传的时候关键超了。大家应该能看的懂吧。

    Android ZXing 2.3.0源码及编译后的core-2.3.0.jar和android-integration-2.3.0.jar打包亲测可用

    (eclipse没有其他项目的话手动建一个就有了,Android是在Android 3.0 (API level 11)开始引入Fragment的,3.0以上开始起为了兼容3.0以下的需要加入这个jar)。 第四步: 右键分别点击core目录和android-...

    Android代码-一个快速方便地访问Android Shared preferences 库。

    It allows you to save any type or list in the sharedpreferences and retrieve it in convenient way. Installation Gradle Add jitpack.io to your root gradle file &#40;project level&#41; : allprojects {...

    Android代码-Sorters

    I'm a Test Analist and as developer I'm at Junior level. If yout would help this project, fell free to join. For now i just implement 3 diferent sorters but I wish to implement more in the future. ...

    Android代码-live-tools

    Live-Tools is a library project which aims to convert some Android device features to LiveData. Live Tool List Live Orientation: Observe orientation changes Live Location: Observe user location (fine...

    Android代码-Android两级磁贴列表,拥有完美的不同级磁贴互相接触推动的效果,适合多级分类嵌套展示。

    An Android library for double level section headers that stick to the top of list. Android widget especially for displaying items with multilevel classification. Usage 1. Include the library in your ...

    Android代码-大头像版通讯录

    Android app to use as the base app for implementing the following material widgets and animations that were introduced in Android 5.0 (API level 21). RecyclerView (the new ListView) CardView (custom ...

    android-viewflow

    The purpose of a FlowIndicator is to present a visual representation of where in the item list focus is at. You may either implement a FlowIndicator yourself or use an implementation provided by the ...

    Android开发艺术探索

    6.2.5 Level List Drawable / 255 6.2.6 Transition Drawable / 256 6.2.7 Inset Drawable / 257 6.2.8 Scale Drawable / 258 6.2.9 Clip Drawable / 260 6.3 自定义Drawable / 262 第7章 Android动画...

    android sdk 自带 实例(samples)

    The list below provides a summary of the sample applications that are available with the Android SDK. Using the links on this page, you can view the source files of the sample applications in your ...

    libusb-1.0.9

    5.使用libusb_free_device_list清除使用libusb_get_device_list获得的队列; 6.通过libusb_claim_interface请求接口(需要你知道设备的接口数值); 7.操作想得到的I/O; 8.通过libusb_release_interface释放设备; 9...

    fastboot 2020年 android10版本 ubuntu linux平台

    devices [-l] List devices in bootloader (-l: with device paths). getvar NAME Display given bootloader variable. reboot [bootloader] Reboot device. locking/unlocking: flashing lock|unlock Lock/...

    android天气查询源码

    currentLevel = LEVEL_PROVINCE; } else { queryFromServer(null, "province"); } } /** * 查询选中省内所有的市,优先从数据库查询,如果没有查询到再去服务器上查询。 */ private void ...

    android开发艺术探索高清完整版PDF

    244 6.2.2 Shape Drawable / 247 6.2.3 Layer Drawable / 251 6.2.4 State List Drawable / 253 6.2.5 Level List Drawable / 255 6.2.6 Transition Drawable / 256 6.2.7 Inset Drawable / 257 6.2.8 Scale ...

    Learning Kotlin by building Android Applications

    where we focus on teaching Android development by building three different Android Application, namely Building you Tic-Tac-Toe application, Developing your location based alarm and lastly a To-Do ...

    菜单UI系统源码UMenu Gallery

    unity 菜单UI系统源码UMenu Gallery ... - Grid Layout Level List. - smooth transition of images. - Tilt UI movement. - Custom Animations. - Save / Load Options. - Highly customizable. - Pretty easy to use.

Global site tag (gtag.js) - Google Analytics