---
title: "android UI入门一"
author: "fokman"
date: "2012-07-24T12:20:41Z"
tags: []
categories: ["移动开发"]
slug: "android-ui"
draft: false
lastmod: "2012-07-24T12:21:13Z"
id: 1605234
url: "https://fokman.iteye.com/blog/1605234"
---

在ios系统中，常常看到绚丽的画面让人心动不已。然而在android开发中，默认的按钮背景都十分的丑陋，今天就给大家写一个类似于ios渐变风格的布局。只要图片做好了，要达到目标很简单。

首选定义一个渐变的背景图片。

![](http://dl.iteye.com/upload/picture/pic/115863/5b1f16e8-9802-3ebb-9ba8-7a97547cf6df.png)

这个大家可以copy到自己本地。

然后在布局文件里面定义这个背景

```
<LinearLayout
        android:id="@+id/loginBottomLayout"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_alignParentBottom="true"
        android:orientation="horizontal"
        android:gravity="right"
        android:background="@drawable/titlebar_bg" >

</LinearLayout>
```

 

其中android:background="@drawable/titlebar\_bg" 就是用来设置背景的

大家可以看看效果：

 ![](http://dl.iteye.com/upload/picture/pic/115865/f2037ba5-e12a-3e6e-a160-89ee29d06404.png)