---
title: "Android UI"
author: "test_angel"
date: "2012-11-23T17:51:21Z"
tags: []
categories: ["移动开发"]
slug: "android-ui"
draft: false
lastmod: "2012-11-23T17:51:21Z"
id: 1734182
url: "https://test-angel.iteye.com/blog/1734182"
---

好久都没写过博客了，现在都不知道从何写起了。

下面就记录一个UI上的小知识点，供以后用。

我们在布局的时候，常常出现在Button或者TextView上显示一个图片加文字，这个时候我们可以自定义组件，达到需要的效果，当然最简单的方式就是使用自带的属性了。下面是对Button、EditText、TextView的小Demo。

 

```
 <Button
         android:layout_width="fill_parent"
        android:layout_height="wrap_content"
         android:drawableLeft="@drawable/ic_launcher"
        android:drawablePadding="50dp"
        android:gravity="left"
        android:text="aaaaaaaaaaaaaaa"   
        />
    
    <EditText 
         android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:drawableLeft="@drawable/ic_launcher"
        android:hint="bbbbbbbbb"
        />
    
    <TextView 
        
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:drawableLeft="@drawable/ic_launcher"
        android:text="cccccccccccc"
        
        />
```

 

其中drawableLeft就是文字左边的图片，同理还有drawableTop  drawableBottom  drawableRight；

drawablePadding是文字与图片的距离。

 

就先写这些了！！！