Advertisement

Android TextView开发实用技巧汇总

阅读量:

1、简介

本篇博客旨在记录在日常开发过程中TextView的各种使用技巧,并以此以便更好地完成后续任务。

2、TextView技巧使用明细

配置HTML5字体样式
mTextTip显示为蓝色文字

配置HTML5字体样式
mTextTip显示为蓝色文字

2.1 TextView 带图标显示

a. 常见的情况包括:android:drawableLeft = " ";该设置实现了右边为文字、左边为图标的效果。

b. setCompoundDrawables 的使用技巧

该API的核心功能包括对TextView控件中的Drawable对象的位置进行精确设置,在Java代码段中非常简便地实现了图标切换及位置调整

以下为案例1 实现图标的切换:

复制代码
    public static void modifyTextViewDrawable(TextView v, Drawable drawable, int index) {

    
     drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
    
     //index 0:左 1:上 2:右 3:下
    
     if (index

全部评论 (0)

还没有任何评论哟~