Android背景色渐变效果(shape,gradient) (转)
生活随笔
收集整理的這篇文章主要介紹了
Android背景色渐变效果(shape,gradient) (转)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Android設置背景色可以通過在res/drawable里定義一個xml,如下:
[代碼]xml代碼:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:startColor="#FFF" android:endColor="#000" android:angle="45" /> </shape> View Codeshape是用來定義形狀的,gradient定義該形狀里面為漸變色填充,startColor起始顏色,endColor結束顏色,angle表示方向角度。當angle=0時,漸變色是從左向右。 然后逆時針方向轉,當angle=90時為從下往上。
實現過程:
第一步:
res/drawable/background_login.xml
[代碼]xml代碼:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:startColor="#FFF" android:endColor="#000" android:angle="45" /> </shape> View Code第二步:
res/layout/login.xml
[代碼]xml代碼:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/background_login"> </LinearLayout> View Code?
第三步:
[代碼]java代碼:
import android.app.Activity; import android.os.Bundle; public class LoginActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.login); } } View Code效果圖:
?
轉自:http://l62s.iteye.com/blog/1659433
轉載于:https://www.cnblogs.com/android-for-dh/p/4423495.html
總結
以上是生活随笔為你收集整理的Android背景色渐变效果(shape,gradient) (转)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 梦到妈妈怀孕预示着什么
- 下一篇: 〖Android〗存在多个Android