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、对比度的调整方法如下:在空屏幕下右击,点击属性,在出现的提示栏里点击设置,设置完对比度之后点击应用,再点击确定就可以了。