1.创建一个clip

clip.xml

<?xml version="1.0" encoding="utf-8"?>

<clip xmlns:android=http://schemas.android.com/apk/res/android

android:drawable="@drawable/android"

android:clipOrientation="horizontal"

android:gravity="left" />

</clip> //后匹配可以不写

2.布局里面加入VIEW

<RelativeLayout

android:layout_width="30.0dip"

android:layout_height="30.0dip"

android:layout_alignParentRight="true"

android:layout_alignParentTop="true"

android:layout_marginRight="200.0dip" >

<ImageView

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:src="@drawable/battery_out" />

<ImageView

android:id="@+id/battery_clipIV"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:src="@drawable/battery_clip" />

</RelativeLayout>

3.编码实现

private ClipDrawable batteryClipDrawable = null;

this.batteryClipDrawable = ((ClipDrawable) ((ImageView) findViewById(R.id.battery_clipIV))

.getDrawable());

this.batteryClipDrawable.setLevel(k * 100);

更多相关文章

  1. android的布局水平与垂直显示
  2. Android实现输入法弹出时把布局顶上去和登录按钮顶上去的解决方
  3. android 布局xml中 android:fitsSystemWindows="true"的作用
  4. Android开发笔记(二)——布局管理器
  5. Android 布局的属性

随机推荐

  1. 获取Android的Java源代码并在Eclipse中关
  2. 当Google忙着忽悠Android的时候,各位别忘
  3. Android中shape的使用
  4. Android(安卓)中文 API――android.widge
  5. android 自定义组件 :对VelocityTracker的
  6. android中控制EditText不可编辑的问题
  7. android基础入门(二)――创建android工程
  8. 2010-11-4
  9. Android架构师之路
  10. 如何退出Android应用程序