StatelistDrawable资源



代码示例

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="true"
        android:color="f44"/>
    <item android:state_focused="false"
        android:color="eee"/>
</selector>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >
  <EditText
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:textColor="@drawable/my_image"/>

</LinearLayout>

LayerDawable资源



代码示例

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@android:id/background"
        android:drawable="@drawable/ic_launcher"/>
    <item android:id="@android:id/progress"
        android:drawable="@drawable/ic_launcher"/>
</layer-list>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <bitmap android:src="@drawable/ic_launcher"
            android:gravity="center"/>
    </item>
    <item android:top="25dp" android:left="25dp">
        <bitmap android:src="@drawable/ic_launcher"
            android:gravity="center"/>
    </item>
    <item android:top="50dp" android:left="50dp">
        <bitmap android:src="@drawable/ic_launcher"
            android:gravity="center"/>
    </item>
</layer-list>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >
  <SeekBar
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:id="@+id/seekBar"
      android:max="100"
      android:progressDrawable="@drawable/my_image"/>
  <ImageView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:src="@drawable/my_bar"/>

</LinearLayout>

ShapeDrawable资源



代码示例

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="#fff"/>
    <padding android:left="7dp"
        android:top="7dp"
        android:bottom="7dp"
        android:right="7dp"/>
    <stroke android:width="3dp"
        android:color="#ff0"/>
</shape>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient android:startColor="#FFFF0000"
        android:endColor="#80FF00FF"
        android:angle="45"/>
    <padding android:left="7dp"
        android:top="7dp"
        android:bottom="7dp"
        android:right="7dp"/>
    <corners android:radius="8dp"/>
</shape>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <gradient android:startColor="#ff0"
        android:endColor="#00f"
        android:angle="45"
        android:type="sweep"/>
    <padding android:left="7dp"
        android:top="7dp"
        android:bottom="7dp"
        android:right="7dp"/>
    <corners android:radius="8dp"/>
</shape>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >
    <EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/my_shape"/>
    <EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/my_shape3"/>
    <EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/my_shape4"/>

</LinearLayout>

ClipDrawable资源



图片换换展开的代码示例

package peng.liu.test;

import android.app.Activity;
import android.graphics.drawable.ClipDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.ImageView;

import java.util.Timer;
import java.util.TimerTask;

public class MainActivity extends Activity{
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ImageView image = (ImageView) findViewById(R.id.image);
        final ClipDrawable clip = (ClipDrawable) image.getDrawable();
        final Handler handler = new Handler(){
            @Override
            public void handleMessage(Message msg) {
                if (msg.what == 0x123){
                    clip.setLevel(clip.getLevel()+200);
                }
            }
        };
        new Timer().schedule(new TimerTask() {
            @Override
            public void run() {
                Message msg = new Message();
                msg.what = 0x123;
                handler.sendMessage(msg);
                if (clip.getLevel() >= 10000){
                    this.cancel();
                }
            }
        },0,200);
    }
}

布局代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/image"
        android:src="@drawable/ic_launcher"/>

</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<clip xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/ic_launcher"
    android:clipOrientation="horizontal"
    android:gravity="center">

</clip>

Animationdrawable资源







package peng.liu.test;

import android.app.Activity;
import android.graphics.drawable.ClipDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

import java.util.Timer;
import java.util.TimerTask;

public class MainActivity extends Activity{
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final ImageView image = (ImageView) findViewById(R.id.image);
        final Animation anim = AnimationUtils.loadAnimation(this,R.anim.my_anim);
        anim.setFillAfter(true);
        findViewById(R.id.btnAnim).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                image.startAnimation(anim);
            }
        });
    }
}
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator"
    android:duration="5000">
    <scale android:fromXScale="1.0"
        android:toXScale="1.4"
        android:fromYScale="1.0"
        android:toYScale="0.6"
        android:pivotX="50%"
        android:pivotY="50%"
        android:fillAfter="true"
        android:duration="2000"/>
    <translate android:fromXDelta="10"
        android:toXDelta="130"
        android:fromYDelta="30"
        android:toYDelta="-80"
        android:duration="2000"/>
</set>

Android的stateListDrawable,layerDawable,clipdrawable,AnimationDarwable介绍-android学习之旅(五十五)的更多相关文章

  1. android布局##TableLayout和FrameLayout-android学习之旅(十五)

    TableLayout 表格布局 tablelayout简介 表格布局有TableLayout代表,但是它的本质定义仍然是线性管理器.表格布局采用行和列来管理UI,但是不需要明确的定义多少行,多少列, ...

  2. android布局Relative和gridLayout-android学习之旅(十六)

    Relative布局简介 相对布局的组件是由兄弟组件和父组价决定的,因此这种布局被称为相对布局. 属性设置介绍 RelativeLayout.Layoutparam中只能设置为true和false的属 ...

  3. Android的RadioButton和checkBox的用法-android学习之旅(十九)

    RadioButton和checkBox简介 单选按钮(RadioButton)和复选框(CheckBox)都继承了Button,因此属性的设置和Button差不多,只是加了一个android:che ...

  4. Android广播接收器Broadcast Receiver-android学习之旅(十二)

    首先继承BroadcastReceiver类,并在manifest中注册 public class MyReceiver extends BroadcastReceiver { public MyRe ...

  5. Android笔记(五十五) Android四大组件之一——ContentProvider,使用系统提供的ContentProvider

    因为在Android中,存储系统联系人姓名和电话是存在与不同的ContentProvider中的,具体如何查找,可以从Android的源代码中查看,在android.providers包中列出了所有系 ...

  6. Android硬件抽象层(HAL)概要介绍和学习计划

    文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/6567257 Android的硬件抽象层,简单来 ...

  7. Android四大组件之一Service介绍-android学习之旅(十二)

    基本概念: service是android四大组件之一,运行在后台执行耗时操作,并不提供用户界面.其他组件如acticity可以通过startService启动该组件,也可以通过bindService ...

  8. Sky(dart)语言介绍-android学习之旅(十)

    认识dart语言 google于2011年10月10日发布了"dart"语言的"早起预览版",google希望利用这款语言,帮助开发者克服javaScript的 ...

  9. Android绘图基础Paint和Canvas介绍-android学习之旅(六十一)

    canvas介绍 Paint类介绍 代码示例 效果图

随机推荐

  1. 入口开始,解读Vue源码(一)-- 造物创世

    Why? 网上现有的Vue源码解析文章一搜一大批,但是为什么我还要去做这样的事情呢?因为觉得纸上得来终觉浅,绝知此事要躬行. 然后平时的项目也主要是Vue,在使用Vue的过程中,也对其一些约定产生了一 ...

  2. git修改远程仓库地址

    方法有三种: 1.修改命令 git remote set-url origin [url] 例如: git remote set-url origin gitlab@gitlab.chumob.com ...

  3. 安装插件出现eclipse An internal error occurred during: "Installing Software". xxxxxxxxx

    就是你自己本来就有那个插件了 百度怎么删吧.... 看一下我这个文章 强烈建议本地安装的时候用第四种安装 http://www.cnblogs.com/ydymz/articles/7203260.h ...

  4. 关于 printf scanf getchar

    float默认小数6位 右对齐.-m 左对齐 在调用printf函数输出数据时,当数据的实际位宽大于printf函数中的指定位宽时,将按照数据的实际位宽输出数据. .n表精度 输出%符号 注意点 #i ...

  5. ubuntu14.04+sublime3+latex配置

    目的:用题目所说的三个东西写论文. 配置方法:参考 http://blog.csdn.net/bleedingfight/article/details/72810606, 但该博客所提的texliv ...

  6. 【已解决】IIS搭建 asp.net core 项目后 其他电脑访问不到资源文件

    IIS搭建asp.net core 项目后,访问不到里面的资源文件(图片等),解决方法如下: 1.检查asp.net core发布文件中的资源文件是不是都放到了wwwroot名称的目录中. 2.检查a ...

  7. Matlab—regexp正则表达式

    原文转自:http://blog.csdn.net/yf210yf/article/details/42421523 关于正则表达式的基本知识 正则表达式就是一个表达式(也是一串字符),它定义了某种字 ...

  8. iOS 中的类属性

    转自:iOS 知识小集 从Xcode 8开始,LLVM已经支持Objective-C显式声明类属性了,这是为了与Swift中的类属性互操作而引入的.在WWDC 2016 What's New in L ...

  9. python模块:网络协议和支持

    python模块:网络协议和支持 webbrowser 调用浏览器显示html文件 webbrowser.open('map.html') [webbrowser - Convenient Web-b ...

  10. ROS新闻 Towards ROS-native drones 无人机支持方案

    PX4/Firmware:https://github.com/PX4/Firmware PXFmini An open autopilot daughter-board for the Raspbe ...