android設置漸變
Ⅰ android 怎麼自定義顏色漸變
1.在res/drawable/里新建XML文件(background_color.xml)
內容:
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#000000"
android:endColor="#FFFFFF"
android:angle="90"
/>
</shape>
備:angle(角度)的值只可為:45 90 135 180等45的倍數
2.在res/layout里使用時:
顏色設置段:Android:src="@drawable/background_color
Ⅱ 怎麼在android上面做出根據形狀來漸變的效果
<shape> Android:shape=["rectangle" | "oval" | "line" | "ring"] 其中rectagle矩形,oval橢圓,line水平直線,ring環形
<shape>中子節點的常用屬性:
<gradient> 漸變
Android:startColor 起始顏色
Android:endColor 結束顏色
Android:angle 漸變角度,0從左到右,90表示從下到上,數值為45的整數倍,默認為0;
Android:type 漸變的樣式 liner線性漸變 radial環形漸變 sweep <solid > 填充
Android:color 填充的顏色
<stroke >描邊
Android:width 描邊的寬度
Android:color 描邊的顏色
Android:dashWidth 表示'-'橫線的寬度
Android:dashGap 表示'-'橫線之間的距離
<corners >圓角
Android:radius 圓角的半徑 值越大角越圓
Android:topRightRadius 右上圓角半徑
Android:bottomLeftRadius 右下圓角角半徑
Android:topLeftRadius 左上圓角半徑
Android:bottomRightRadius 左下圓角半徑
<padding >填充
android:bottom="1.0dip" 底部填充
android:left="1.0dip" 左邊填充
android:right="1.0dip" 右邊填充
android:top="0.0dip" 上面填充
Selector
根據不同的選定狀態來定義不同的現實效果 分為四大屬性:
android:state_selected 是選中
android:state_focused 是獲得焦點
android:state_pressed 是點擊
android:state_enabled 是設置是否響應事件,指所有事件
android:state_window_focused 默認時的背景圖片 引用位置:res/drawable/文件的名稱.xml
使用的方法:
Java代碼中:R.drawable.文件的名稱 XML中:Android:background="@drawable/文件的名稱"
示例:
<?xml version="1.0" encoding="utf-8" ?>
<selector xmlns:Android="http://schemas.android.com/apk/res/android">
<!-- 默認時的背景圖片-->
<item Android:drawable="@drawable/pic1" />
<!-- 沒有焦點時的背景圖片 -->
<item
Android:state_window_focused="false"
android:drawable="@drawable/pic_blue"
/>
<!-- 非觸摸模式下獲得焦點並單擊時的背景圖片 -->
<item
Android:state_focused="true"
android:state_pressed="true"
android:drawable= "@drawable/pic_red"
/>
<!-- 觸摸模式下單擊時的背景圖片-->
<item
Android:state_focused="false"
Android:state_pressed="true"
Android:drawable="@drawable/pic_pink"
/>
<!--選中時的圖片背景-->
<item
Android:state_selected="true"
android:drawable="@drawable/pic_orange"
/>
<!--獲得焦點時的圖片背景-->
<item
Android:state_focused="true"
Android:drawable="@drawable/pic_green"
/>
</selector>
layer-list(多個shape)
將多個圖片或上面兩種效果按照順序層疊起來
示例:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap android:src="@drawable/android_red"
android:gravity="center" />
</item>
<item android:top="10dp" android:left="10dp">
<bitmap android:src="@drawable/android_green"
android:gravity="center" />
</item>
<item android:top="20dp" android:left="20dp">
<bitmap android:src="@drawable/android_blue"
android:gravity="center" />
</item>
</layer-list>
感覺很像多個drawable
三者可以結合使用
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<layer-list>
<item android:bottom="8.0dip">
<shape>
<solid android:color="#ffaaaaaa" />
</shape>
</item>
<item>
<shape>
<corners android:bottomLeftRadius="4.0dip" android:bottomRightRadius="4.0dip" android:topLeftRadius="1.0dip" android:topRightRadius="1.0dip" />
<solid android:color="#ffaaaaaa" />
<padding android:bottom="1.0dip" android:left="1.0dip" android:right="1.0dip" android:top="0.0dip" />
</shape>
</item>
<item>
<shape>
<corners android:bottomLeftRadius="3.0dip" android:bottomRightRadius="3.0dip" android:topLeftRadius="1.0dip" android:topRightRadius="1.0dip" />
<solid android:color="@color/setting_item_bgcolor_press" />
</shape>
</item>
</layer-list>
</item>
<item>
<layer-list>
<item android:bottom="8.0dip">
<shape>
<solid android:color="#ffaaaaaa" />
</shape>
</item>
<item>
<shape>
<corners android:bottomLeftRadius="4.0dip" android:bottomRightRadius="4.0dip" android:topLeftRadius="1.0dip" android:topRightRadius="1.0dip" />
<solid android:color="#ffaaaaaa" />
<padding android:bottom="1.0dip" android:left="1.0dip" android:right="1.0dip" android:top="0.0dip" />
</shape>
</item>
<item>
<shape>
<corners android:bottomLeftRadius="3.0dip" android:bottomRightRadius="3.0dip" android:topLeftRadius="1.0dip" android:topRightRadius="1.0dip" />
<solid android:color="@color/setting_item_bgcolor" />
</shape>
</item>
</layer-list>
</item>
</selector>
Ⅲ android imageview 顏色漸變實現三維效果怎麼弄
步驟1:打好文字,選擇工具欄上的【互動式立體化工具】,拉動文字,可根據立體方向和大小進行拉動。 步驟2:選擇屬性欄上的【顏色】-【使用遞減的顏色】,設置好兩個相互漸變的顏色,最好是同類色系的漸變,如大紅色和深紅色。 步驟3:選擇文字,按加號鍵,復制出一個文字層,將復制的文字顏色修改為搭配立體背景的顏色。
Ⅳ android標題欄透明度漸變
<alpha>標簽為alpha透明度節點
android:fromAlpha="1.0" 設置動畫起始透明度為1.0 表示完全不透明
android:toAlpha="0.0"設置動畫結束透明度為0.0 表示完全透明
也就是說alpha的取值范圍為0.0 - 1.0 之間
這個動畫布局設置動畫從完全不透明漸變到完全透明。
view plain
<?xml
version="1.0"
encoding="utf-8"?>
<alpha
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:repeatCount="infinite"
android:ration="2000">
</alpha>
代碼實現
view plain
import android.app.Activity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
public
class AlphaActivity extends Activity {
/**顯示動畫的ImageView**/
ImageView mImageView = null;
/**透明動畫**/
Animation mAnimation = null;
@Override
public
void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.translate);
/**拿到ImageView對象**/
mImageView = (ImageView)findViewById(R.id.imageView);
/**載入透明動畫**/
mAnimation = AnimationUtils.loadAnimation(this, R.anim.alpha);
/**播放透明動畫**/
mImageView.startAnimation(mAnimation);
}
}
Ⅳ android怎麼用paint實現圖像的漸變出現
其他的和線性漸變相同。為了演 示圖像漸變效果。
一, float radius, float x1。
SweepGradient(float cx。
LinearGradient(float x0,所以建議使用下面的重載方法,他們的基類為android、RadialGradient鏡像漸變
有了上面的基礎. If positions is NULL,代碼如下,他們的不同之處為參數中第一種方法可以用顏色數組, int color1, float radius;/,然後通過載入的顏色來平均的漸變渲染, the drawing may proce unexpected results, int[] colors.RED,p).TileMode tile)
使用實例如下.TileMode, float[] positions; /, int color0,最後參數為平鋪方式, Shader,100, float y0. If the values are not monotonic.graphics, float y1,這里設置為鏡像
剛才已經講到Gradient是基於Shader類,前兩個參數為中心點.TileMode tile)
LinearGradient(float x0.drawCicle(0;
canvas.Shader,參數三和四分辨對應漸變終點.TileMode tile)
三, int color0,所以我們通過Paint的setShader方法來設置這個漸變,200,則漸變將會逐一處理。
二, float[] positions,徑向漸變第三個參數是半徑, int[] colors在android, beginning with 0 and ending with 1,本方法一般為NULL即可.、SweepGradient角度漸變
對於一些3D立體效果的漸變可以嘗試用角度漸變來完成一個圓錐形, float cy. The relative position of each corresponding color in the colors array.setShader(lg),和位置來實現更細膩的過渡效果, 比如顏 色采樣int[] colors數組中存放20種顏色, float x1,Shader。
RadialGradient(float x, float[] positions) /。而第二種方法參數僅為起初顏色color0和最終顏色color1, Shader。和上面參數唯一不同的是, then the colors are automatically spaced evenly,0, float y,了解這些對打好Android游戲開發的基礎很有好處;對於最後一個參數SDK上的描述為May be NULL.graphics中提供了有關Gradient字樣的類, Shader。
SweepGradient(float cx;參數3為畫圓的半徑;
LinearGradient lg=new LinearGradient(0,希望大家對圖像特效處理有了一定的認識,0,參數二為y軸位置,我們一起來了解下徑向漸變;/,類型為float型,相對來說比上面更簡單,Color; /, int color1)
到此,100,Color.TileMode tile)
RadialGradient(float x.MIRROR).BLUE, float y0, int color0,例如LinearGradient線性漸變:
p, int color1、LinearGradient線性漸變
在android平台中提供了兩種重載方式來實例化該類分別為,下面給出一個簡單的實例, int[] colors, float cy, Shader, float y1;參數一為漸變起初點坐標x位置:
Paint p=new Paint(), float y.0、 RadialGradient徑向漸變和SweepGradient角度漸變三種。
Ⅵ android怎麼設置字體漸變色 不是背景漸變
●使用XML的方式為背景添加漸變效果
1、在res/drawable文件夾里添加一個jbshape.xml文件,然後寫入如下代碼:
<?xml version="1.0" encoding="utf-8"?>
<gradient
android:angle="270"
android:centerColor="#00FFFF"
android:centerX="0.5"
android:centerY="0.5"
android:endColor="#666666"
android:startColor="#0099FF" />
<padding
android:bottom="7dp"
android:left="7dp"
android:right="7dp"
android:top="7dp" />
<corners android:radius="4dp" />
</shape>
說明:
(1)shape節點配置的是圖形的形式,主要包括方形、圓形等,上邊代碼為方形。
(2)gradient節點主要配置起點顏色、終點顏色及中間點的顏色、坐標、漸變效果(0,90,180從左到右漸變,270從上到下漸變)默認從左到右。
(3)corners節點配置四周圓角的半徑。
Ⅶ android 如何實現背景圖片漸變切換
解決方案1:
其他的和線性漸變相同。為了演 示圖像漸變效果。
一, float radius, float x1。
SweepGradient(float cx。
LinearGradient(float x0,所以建議使用下面的重載方法,他們的基類為android、RadialGradient鏡像漸變
有了上面的基礎. If positions is NULL,代碼如下,他們的不同之處為參數中第一種方法可以用顏色數組, int color1, float radius;/,然後通過載入的顏色來平均的漸變渲染, the drawing may proce unexpected results, int[] colors.RED,p).TileMode tile)
使用實例如下.TileMode, float[] positions; /, int color0,最後參數為平鋪方式, Shader,100, float y0. If the values are not monotonic.graphics, float y1,這里設置為鏡像
剛才已經講到Gradient是基於Shader類,前兩個參數為中心點.TileMode tile)
LinearGradient(float x0.drawCicle(0;
canvas.Shader,參數三和四分辨對應漸變終點.TileMode tile)
三, int color0,所以我們通過Paint的setShader方法來設置這個漸變,200,則漸變將會逐一處理。
二, float[] positions,徑向漸變第三個參數是半徑, int[] colors在android, beginning with 0 and ending with 1,本方法一般為NULL即可.、SweepGradient角度漸變
對於一些3D立體效果的漸變可以嘗試用角度漸變來完成一個圓錐形, float cy. The relative position of each corresponding color in the colors array.setShader(lg),和位置來實現更細膩的過渡效果, 比如顏 色采樣int[] colors數組中存放20種顏色, float x1,Shader。
RadialGradient(float x, float[] positions) /。而第二種方法參數僅為起初顏色color0和最終顏色color1, Shader。和上面參數唯一不同的是, then the colors are automatically spaced evenly,0, float y,了解這些對打好Android游戲開發的基礎很有好處;對於最後一個參數SDK上的描述為May be NULL.graphics中提供了有關Gradient字樣的類, Shader。
SweepGradient(float cx;參數3為畫圓的半徑;
LinearGradient lg=new LinearGradient(0,希望大家對圖像特效處理有了一定的認識,0,參數二為y軸位置,我們一起來了解下徑向漸變;/,類型為float型,相對來說比上面更簡單,Color; /, int color1)
到此,100,Color.TileMode tile)
RadialGradient(float x.MIRROR).BLUE, float y0, int color0,例如LinearGradient線性漸變:
p, int color1、LinearGradient線性漸變
在android平台中提供了兩種重載方式來實例化該類分別為,下面給出一個簡單的實例, int[] colors, float cy, Shader, float y1;參數一為漸變起初點坐標x位置:
Paint p=new Paint(), float y.0、 RadialGradient徑向漸變和SweepGradient角度漸變三種。
Ⅷ android 動態設置按鈕背景的漸變顏色
在一個xml文件中定義需要用到gradient,然後用drawable設置,大致是這樣
Ⅸ android程序調節屏幕亮度怎麼去掉漸變,比如最高亮度調到最低立馬變黑,而不是慢慢的變化
1、筆記本電腦的顯示器的亮度調整方法如下:首先您要看一下鍵盤上的fn鍵和那兩個亮度的標志(標志就像一個太陽,向上調亮,向下調暗)在那位置才行,一般的手提的這兩個標志均設計在F1-F12上,您認真看一下就可以找到了,然後按住fn健,如果您要調得亮一些,再按向上的標志,如果您要調暗,就按住fn鍵再點按向下的標志。
2、對比度的調整方法如下:在空屏幕下右擊,點擊屬性,在出現的提示欄里點擊設置,設置完對比度之後點擊應用,再點擊確定就可以了。