MainActivity例如下列:

package cc.testcompounddrawables;

import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.widget.TextView;
/**
* Demo描写叙述:
* 測试getCompoundDrawables()方法.
* Returns drawables for the left, top, right, and bottom borders.
* 该方法返回包括控件左,上,右,下四个位置的Drawable的数组
*/
public class MainActivity extends Activity {
private TextView mTextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
init();
}
private void init(){
mTextView=(TextView) findViewById(R.id.textView);
Drawable [] drawables=mTextView.getCompoundDrawables();
for (int i = 0; i < drawables.length; i++) {
Drawable drawable=drawables[i];
System.out.println("第"+i+"张图片 width="+drawable.getBounds().width()+
",height="+drawable.getBounds().height());
}
} }

main.xml例如以下:

<RelativeLayout 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" > <TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableBottom="@drawable/ic_launcher"
android:drawableLeft="@drawable/ic_launcher"
android:drawableRight="@drawable/ic_launcher"
android:drawableTop="@drawable/ic_launcher"
android:text="測试getCompoundDrawables()方法"
android:gravity="center"
android:layout_centerInParent="true"
/> </RelativeLayout>

版权声明:本文博主原创文章,博客,未经同意不得转载。

TextView于getCompoundDrawables()使用演示样本的方法的更多相关文章

  1. Cocos2d-x 3.2 Lua演示样本CocosDenshionTest(音频测试)

    Cocos2d-x 3.2 Lua演示样本CocosDenshionTest(音频测试)  本篇博客介绍Cocos2d-x 3.2中Lua演示样例的音频測试.Cocos2d-x使用SimpleAudi ...

  2. Cocos2d-x 3.2 Lua演示样本 ActionTest(操作测试)

    Cocos2d-x 3.2 Lua演示样本 ActionTest(操作测试) 2014年博文大赛,请投上您宝贵的一票:http://vote.blog.csdn.net/Article/Details ...

  3. 模式识别 - 处理多个演示样本研究(MIL)特点(matlab)

    处理多个演示样本研究(MIL)特点(matlab) 本文地址: http://blog.csdn.net/caroline_wendy/article/details/27206325 多演示样例学习 ...

  4. java注意事项演示 地图产生表 演示样本 来自thinking in java 4 20代码的章

    java注意事项演示 地图产生表 演示样本  来自thinking in java 4 20代码的章 thinking in java 4免费下载:http://download.csdn.net/d ...

  5. TextView不用ScrollViewe也可以滚动的方法

    转自:http://www.jb51.net/article/43377.htm android TextView不用ScrollViewe也可以滚动的方法. TextView textview = ...

  6. Asp.net固定功能位充满了零(解决,演示样本)!

    Asp.net固定功能位充满了零(解决.演示样本)! 在发展,其中,数实现出现8数字.但是,需要使用0加厚.例如:123,代表:0000123. 真实的比例,如下: decimal aaa = 123 ...

  7. WebGL自学教程——WebGL演示样本:开始

    最终开始WebGL样品演示,...... 开始 使用WebGL步骤,非常easy: 1. 获得WebGL的渲染环境(也叫渲染上下文). 2. 发挥你的想象力,利用<WebGL參考手冊>中的 ...

  8. Notification(一个)——使用演示样本的基础知识

    main.xml如下面: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" ...

  9. Java8的日期和时间的库20经常使用的演示样本

    除了lambda表达,stream以及从一些小的改进,Java 8还推出了新的日期和时间API,在本教程中,我们将展示通过几个简单的任务来学习如何使用示例Java 8这组API.Java至今.日历和时 ...

随机推荐

  1. java读取XML文件的四种方式

    java读取XML文件的四种方式 Xml代码 <?xml version="1.0" encoding="GB2312"?> <RESULT& ...

  2. Java中的statickeyword具体解释

    1.statickeyword主要有2个作用: ①为某特定的数据类型或者对象分配单一的存储空间.而与创建对象的个数无关. ②在不创建对象的情况下能够直接通过类名来直接调用方法或者使用类的属性. 2.s ...

  3. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    在使用Hibernate的J2EE项目中,莫名其妙出现如上错误,既不报错,也不运行不论什么输出測试代码,更不返回结果. 经过排查,在方法里面引用的实体类和其映射文件属性个数不一致. 改动一致后,即解决 ...

  4. jQuery上传插件Uploadify 3.2在.NET下的详细例子

    项目中要使用Uploadify 3.2来实现图片上传并生成缩略通的功能,特此记下来,以供各位参考! Uploadify下载地址:http://www.uploadify.com/download/ 下 ...

  5. OCP读书笔记(19) - 数据库空间管理

    传输表空间:将linux下的数据库中的test表空间传输到windows平台下的数据库 在传输表空间前,先确定一下源库与目标数据库字符集一致: select * from nls_database_p ...

  6. 使用zTree和json构建简单树节点

    我们经常碰到须要构建树结构展示的情况,我推荐使用zTree和JSON. 比如: <? php /** * * 使用zTree和json构建树节点 * */ $arr = array( 0=> ...

  7. MySQL先进的技术-存储引擎

    MySQL功能被分成两部分,主要有成品的外部client连接和可行性研究SQL函数语句,内侧部分被称为存储引擎,它负责接收外部操作指令数据,实际数据是完整的,文件输入和输出操作的工作 版权声明:本文博 ...

  8. POJ 3100 &amp; ZOJ 2818 &amp; HDU 2740 Root of the Problem(数学)

    题目链接: POJ:id=3100" style="font-size:18px">http://poj.org/problem? id=3100 ZOJ:http ...

  9. Linux下 目录 压缩 解压缩 打包

    http://blog.sina.com.cn/s/blog_7479f7990100zwkp.html tar -zcvf /home/xahot.tar.gz /xahot    tar -zcv ...

  10. 通达OA 新旧两种数据库连接方式

    老的连接方式: include_once("/inc/conn.php"); $cursor = exequery($connection,$query); 新的连接方式: inc ...