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. Linux lamp环境编译安装

    1.安装准备: 1)httpd-2.0.52.tar.gz 2)mysql-4.1.12.tar.gz 3)libxml2-2.6.27.tar 4)freetype-2.1.10.tar 5)gd- ...

  2. 一个linux常见命令的列表

    这是一个linux常见命令的列表. 那些有• 标记的条目,你可以直接拷贝到终端上而不需要任何修改,因此你最好开一个终端边读边剪切&拷贝. 所有的命令已在Fedora和Ubuntu下做了测试 命 ...

  3. 如何用C#使用java

    如何使用C#调用Java 今天需要使用C#调用Java的包,研究了一下,大体是以下几种解决方案: 把Java包转换为DLL或者EXE后注册为com组件,之后调用. 使用web service 比如:H ...

  4. art patchoat

    Add patchoat tool to Art. Add a new executable called patchoat to art. This tool takes alreadycompil ...

  5. MVC 学习 区域

    http://www.cnblogs.com/fly_dragon/archive/2011/10/12/2209438.html

  6. elasticsearch2.2

    elasticsearch2.2 集群搭建各种坑     目前生产环境的es版本是1.0版本,需要升级到最新的2.2版本,于是在测试环境进行部署集群测试,在测试过程中遇到的坑相当多,下面详细介绍下. ...

  7. 《深入Java虚拟机》笔记:指令集 (转)

    <深入Java虚拟机>笔记:指令集   指令 含义 iconst_m1 把int型常量-1压入栈中 iconst_0 把int型常量压入栈中 fconst_1 把float型常量1压入栈中 ...

  8. 【UFLDL】多层神经网络

    请参见原始英文教程地址:http://ufldl.stanford.edu/tutorial/supervised/MultiLayerNeuralNetworks 本文是在学习该教程时记得笔记,供參 ...

  9. JDBC批处理executeBatch

    JDBC运行SQL声明,有两个处理接口,一PreparedStatement,Statement,一般程序JDBC有多少仍然比较PreparedStatement 只要运行批处理,PreparedSt ...

  10. 同一个存储过程中,不能多次select into 到同一张表的问题

    表记录的插入方式有两种.其一,先create table 再 insert into from ....其二, 直接 select into. 第一种方式,由于要记录日志,因此IO消耗更多,durat ...