shape详解

shape标签详解,手把手教你写Android项目文档 简历首选内推方式,速度快,效率高啊!然后可以在拉钩,boss,脉脉,大街上看看。简历上写道熟悉什么技术就一定要去熟悉它,不然被问到不会很尴尬!做过什么项目,即使项目体量不大,但也一定要熟悉实现原理!不是你负责的部分,也可以看看同事是怎么实现的,换你来做你会怎么做?做过什么,会什么是广度问题,取决于项目内容。但做过什么,达到怎样一个境界,这是深度问题,和个人学习能力和解决问题的态度有关了。大公司看深度,小公司看广度。大公司面试你会的,小公司面试他们用到的你会不会,也就是岗位匹配度。 阅读详情

一、简单使用

刚开始,就先不讲一堆标签的意义及用法,先简单看看shape标签怎么用。

1、新建shape文件

首先在res/drawable文件夹下,新建一个文件,命名为:shape_radius.xml

内容是这样的:(先不需要理解,先看shape怎么用)

 

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android" > 
  3.     <corners android:radius="20dip"/> 
  4.     <solid android:color="#ff00ff"/> 
  5.  
  6. </shape> 
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <corners android:radius="20dip"/>
    <solid android:color="#ff00ff"/>

</shape>

2、添加到控件中

在定义好shape文件后,下一步就是将其添加到控件中,添加到控件中,一般是使用设置background属性,将其为控件背景,下面,我们将其设置为MainActivity对应的布局中(activity_main.xml),将其设为TextView的背景,看显示出来 是什么样子的。

 

 

  1. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  2.     xmlns:tools="http://schemas.android.com/tools" 
  3.     android:layout_width="match_parent" 
  4.     android:layout_height="match_parent" 
  5.     tools:context="com.harvic.tryshape.MainActivity" > 
  6.  
  7.     <TextView 
  8.         android:layout_width="wrap_content" 
  9.         android:layout_height="wrap_content" 
  10.         android:layout_margin="50dip" 
  11.         android:text="@string/hello_world"  
  12.         android:background="@drawable/shape_radius"/> 
  13.      
  14. </RelativeLayout> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.harvic.tryshape.MainActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="50dip"
        android:text="@string/hello_world" 
        android:background="@drawable/shape_radius"/>
    
</RelativeLayout>

显示出来的结果是这样的:

 

二、基本属性(corners、gradient、padding、size、solid、stroke)

上面给大家简单的讲了下shape标签组的简单使用方法,下面就具体讲讲shape标签里所具有的几个子标签及所具有的属性。

1、Corners

 

  1. <corners    //定义圆角   
  2.     android:radius="dimension"      //全部的圆角半径   
  3.     android:topLeftRadius="dimension"   //左上角的圆角半径   
  4.     android:topRightRadius="dimension"  //右上角的圆角半径   
  5.     android:bottomLeftRadius="dimension"    //左下角的圆角半径   
  6.     android:bottomRightRadius="dimension" />    //右下角的圆角半径   
<corners    //定义圆角  
    android:radius="dimension"      //全部的圆角半径  
    android:topLeftRadius="dimension"   //左上角的圆角半径  
    android:topRightRadius="dimension"  //右上角的圆角半径  
    android:bottomLeftRadius="dimension"    //左下角的圆角半径  
    android:bottomRightRadius="dimension" />    //右下角的圆角半径  

Corners标签是用来字义圆角的,其中radius与其它四个并不能共同使用。

 

android:radius:定义四个角的的圆角半径。

其它四个是逐个字义每个角的圆角半径。

使用:

控件布局:

 

  1. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  2.     android:layout_width="match_parent" 
  3.     android:layout_height="match_parent" > 
  4.  
  5.     <TextView 
  6.         android:layout_width="100dp" 
  7.         android:layout_height="100dp" 
  8.         android:layout_margin="50dip" 
  9.         android:text="@string/hello_world"  
  10.         android:background="@drawable/shape_radius"/> 
  11. </RelativeLayout> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <TextView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_margin="50dip"
        android:text="@string/hello_world" 
        android:background="@drawable/shape_radius"/>
 </RelativeLayout>

shape定义:

 

 

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android" > 
  3.     <corners android:radius="20dip"/> 
  4.     <solid android:color="#ffff00"/> 
  5. </shape> 
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <corners android:radius="20dip"/>
    <solid android:color="#ffff00"/>
</shape>

效果:

 

2、solid

solid用以指定内部填充色

只有一个属性:

 

  1. <solid  android:color="color" />   
<solid  android:color="color" />  

在上面的例子中,我们就将填充色指定为#ffff00了,如果我们不加圆角,只使用填充色,即将shape变成这样子:

 

 

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android" > 
  3.     <solid android:color="#ffff00"/> 
  4. </shape> 
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <solid android:color="#ffff00"/>
</shape>

那效果就是这样的:

 

3、gradient

 

gradient用以定义渐变色,可以定义两色渐变和三色渐变,及渐变样式,它的属性有下面几个:

 

  1. <gradient  
  2.     android:type=["linear" | "radial" | "sweep"]    //共有3中渐变类型,线性渐变(默认)/放射渐变/扫描式渐变   
  3.     android:angle="integer"     //渐变角度,必须为45的倍数,0为从左到右,90为从上到下   
  4.     android:centerX="float"     //渐变中心X的相当位置,范围为0~1   
  5.     android:centerY="float"     //渐变中心Y的相当位置,范围为0~1   
  6.     android:startColor="color"   //渐变开始点的颜色   
  7.     android:centerColor="color"  //渐变中间点的颜色,在开始与结束点之间   
  8.     android:endColor="color"    //渐变结束点的颜色   
  9.     android:gradientRadius="float"  //渐变的半径,只有当渐变类型为radial时才能使用   
  10.     android:useLevel=["true" | "false"] />  //使用LevelListDrawable时就要设置为true。设为false时才有渐变效果   
<gradient 
    android:type=["linear" | "radial" | "sweep"]    //共有3中渐变类型,线性渐变(默认)/放射渐变/扫描式渐变  
    android:angle="integer"     //渐变角度,必须为45的倍数,0为从左到右,90为从上到下  
    android:centerX="float"     //渐变中心X的相当位置,范围为0~1  
    android:centerY="float"     //渐变中心Y的相当位置,范围为0~1  
    android:startColor="color"   //渐变开始点的颜色  
    android:centerColor="color"  //渐变中间点的颜色,在开始与结束点之间  
    android:endColor="color"    //渐变结束点的颜色  
    android:gradientRadius="float"  //渐变的半径,只有当渐变类型为radial时才能使用  
    android:useLevel=["true" | "false"] />  //使用LevelListDrawable时就要设置为true。设为false时才有渐变效果  

首先有三种渐变类型,分别是:linear(线性渐变)、radial(放射性渐变)、sweep(扫描式渐变)

(1)先看看这几个属性的使用方法:

 

  1. android:type=["linear" | "radial" | "sweep"] 
  2. android:startColor="color"   //渐变开始点的颜色   
  3. android:centerColor="color"  //渐变中间点的颜色,在开始与结束点之间   
  4. android:endColor="color"    //渐变结束点的颜色   
  5. android:gradientRadius="float"  //渐变的半径,只有当渐变类型为radial时才能使用   
android:type=["linear" | "radial" | "sweep"]
android:startColor="color"   //渐变开始点的颜色  
android:centerColor="color"  //渐变中间点的颜色,在开始与结束点之间  
android:endColor="color"    //渐变结束点的颜色  
android:gradientRadius="float"  //渐变的半径,只有当渐变类型为radial时才能使用  

 

下面我们使用三色渐变来看看这三种渐变方式都是怎么显示的:(如果不使用centerColor属性就是双色渐变,这个属性是可选的)

需要注意的一点是,在构造放射性渐变时,要加上android:gradientRadius属性(渐变半径),即必须指定渐变半径的大小才会起作用,下面列出这三个渐变方式的shape代码,供大家参考:

线性渐变:

 

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android" > 
  3.     <gradient  
  4.         android:type="linear" 
  5.         android:startColor="#ff0000" 
  6.         android:centerColor="#00ff00" 
  7.         android:endColor="#0000ff"/> 
  8. </shape> 
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <gradient 
        android:type="linear"
        android:startColor="#ff0000"
        android:centerColor="#00ff00"
        android:endColor="#0000ff"/>
</shape>

放射性渐变:

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android" > 
  3.     <gradient  
  4.         android:type="radial" 
  5.         android:startColor="#ff0000" 
  6.         android:centerColor="#00ff00" 
  7.         android:endColor="#0000ff" 
  8.         android:gradientRadius="100"/> 
  9. </shape> 
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <gradient 
        android:type="radial"
        android:startColor="#ff0000"
        android:centerColor="#00ff00"
        android:endColor="#0000ff"
        android:gradientRadius="100"/>
</shape>

扫描式渐变:

 

 

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android" > 
  3.     <gradient  
  4.         android:type="sweep" 
  5.         android:startColor="#ff0000" 
  6.         android:centerColor="#00ff00" 
  7.         android:endColor="#0000ff"/> 
  8. </shape> 
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <gradient 
        android:type="sweep"
        android:startColor="#ff0000"
        android:centerColor="#00ff00"
        android:endColor="#0000ff"/>
</shape>

可见放射性渐变,只是比其它两个多了个android:gradientRadius属性

(2)、android:angle属性(仅对线性渐变有效)

 

  1. android:angle="integer"     //渐变角度,必须为45的倍数,0为从左到右,90为从上到下   
android:angle="integer"     //渐变角度,必须为45的倍数,0为从左到右,90为从上到下  

我们在上面的三种渐变上都加上angle属性,看看效果如何:

能过跟上一个图对比可以发现,angle属性确实只对线性渐变有效,其它两种渐变方式都没有任何动静,下面是此时的线性渐变shape代码:

 

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android" > 
  3.     <gradient  
  4.         android:type="linear" 
  5.         android:startColor="#ff0000" 
  6.         android:centerColor="#00ff00" 
  7.         android:endColor="#0000ff" 
  8.         android:angle="45"/> 
  9. </shape> 
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <gradient 
        android:type="linear"
        android:startColor="#ff0000"
        android:centerColor="#00ff00"
        android:endColor="#0000ff"
        android:angle="45"/>
</shape>
(3)、android:centerX与android:centerY

centerX、centerY两个属性用于设置渐变的中心点位置,仅当渐变类型为放射渐变时有效,类型为分数或小数,不接受Dimension。默认值是0.5,有效值是0.0~1.0,超出该范围后会看不出渐变效果。centerX、centerY的取值其实是宽和高的百分比;不难理解,下面看代码:

 

 

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android" > 
  3.     <gradient  
  4.         android:type="sweep" 
  5.         android:startColor="#ff0000" 
  6.         android:centerColor="#00ff00" 
  7.         android:endColor="#0000ff" 
  8.         android:centerX="0.2" 
  9.         android:centerY="0.8"/> 
  10. </shape> 
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <gradient 
        android:type="sweep"
        android:startColor="#ff0000"
        android:centerColor="#00ff00"
        android:endColor="#0000ff"
        android:centerX="0.2"
        android:centerY="0.8"/>
</shape>

取宽度的20%和高度的80%的位置,作为新的渐变原点,效果是这样的:

 

(4)android:useLevel

useLevel属性通常不使用。该属性用于指定是否将该shape当成一个LevelListDrawable来使用,默认值为false。

4、stroke

这是描边属性,可以定义描边的宽度,颜色,虚实线等

  1. <stroke        
  2.     android:width="dimension"   //描边的宽度   
  3.     android:color="color"   //描边的颜色   
  4.     // 以下两个属性设置虚线   
  5.     android:dashWidth="dimension"   //虚线的宽度,值为0时是实线   
  6.     android:dashGap="dimension" />      //虚线的间隔  
<stroke       
    android:width="dimension"   //描边的宽度  
    android:color="color"   //描边的颜色  
    // 以下两个属性设置虚线  
    android:dashWidth="dimension"   //虚线的宽度,值为0时是实线  
    android:dashGap="dimension" />      //虚线的间隔 

 

上面各个属性的意义如下:

我们使用绿色虚线描边,虚线高度是20dp,虚线宽度为10dp虚线间距为1dp:

 

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android" > 
  3.     <stroke  
  4.         android:width="20dp"  
  5.         android:color="#00ff00" 
  6.         android:dashWidth="10dp" 
  7.         android:dashGap="1dp" /> 
  8. </shape> 
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <stroke 
        android:width="20dp" 
        android:color="#00ff00"
        android:dashWidth="10dp"
        android:dashGap="1dp" />
</shape>

从效果图中,我们也能清晰的看出这三个参数(width、dashwidth、dashGap)之间的区别:

 

5、size和padding

这两个基本上不怎么用,因为他们所具有的功能,控件本身也能实现。 size:是用来定义图形的大小的。

 

  1. <size   
  2.     android:width="dimension"   
  3.     android:height="dimension" /> 
<size  
    android:width="dimension"  
    android:height="dimension" />

padding:用来定义内部边距

  1. <padding    
  2.     android:left="dimension"   
  3.     android:top="dimension"   
  4.     android:right="dimension"   
  5.     android:bottom="dimension" /> 
<padding   
    android:left="dimension"  
    android:top="dimension"  
    android:right="dimension"  
    android:bottom="dimension" />

三、Shape的属性(rectangle、oval、line、ring)

上面我们讲了Shape的子标签的的作用,但Shape本身还没讲,Shape自已是可以定义当前Shape的形状的,比如上面的矩形,还有椭圆形,线形和环形;这些都是通过Shape标签的 shape属性来定义的,Shape标签总共有下面几个属性,我们一个个讲:

 

  1. android:shape=["rectangle" | "oval" | "line" | "ring"]   
  2. shape的形状,默认为矩形,可以设置为矩形(rectangle)、椭圆形(oval)、线性形状(line)、环形(ring)   
  3. 下面的属性只有在android:shape="ring时可用:   
  4. android:innerRadius         尺寸,内环的半径。   
  5. android:innerRadiusRatio    浮点型,以环的宽度比率来表示内环的半径,   
  6. android:thickness           尺寸,环的厚度   
  7. android:thicknessRatio      浮点型,以环的宽度比率来表示环的厚度,例如,如果android:thicknessRatio="2",   
  8. android:useLevel            boolean值,如果当做是LevelListDrawable使用时值为true,否则为false.  
android:shape=["rectangle" | "oval" | "line" | "ring"]  
shape的形状,默认为矩形,可以设置为矩形(rectangle)、椭圆形(oval)、线性形状(line)、环形(ring)  
下面的属性只有在android:shape="ring时可用:  
android:innerRadius         尺寸,内环的半径。  
android:innerRadiusRatio    浮点型,以环的宽度比率来表示内环的半径,  
android:thickness           尺寸,环的厚度  
android:thicknessRatio      浮点型,以环的宽度比率来表示环的厚度,例如,如果android:thicknessRatio="2",  
android:useLevel            boolean值,如果当做是LevelListDrawable使用时值为true,否则为false. 

可见,只有第一个shape是可用的,其它五个都是shape等于ring时所特有的。

 

注意,无论这里shape取什么形状,他的子标签都是可用的,但有时并不会有效果,比如在shape为椭圆时,那corners标签就不会有效果,很显然的道理。下面一个个看看各个形状都是怎么样的;

1、rectangle (矩形)

这就是上一节我们使用的形状,当我们不指定shape属性时,默认就是矩形的。

控件代码:

 

  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  2.     android:layout_width="match_parent" 
  3.     android:layout_height="match_parent" 
  4.     android:orientation="horizontal" >     
  5.     <TextView 
  6.         android:layout_width="300dp" 
  7.         android:layout_height="100dp" 
  8.         android:layout_margin="10dp" 
  9.         android:textColor="#ffffff" 
  10.         android:textSize="18sp" 
  11.         android:textStyle="bold" 
  12.         android:background="@drawable/try_shape_3"/> 
  13. </LinearLayout> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >    
    <TextView
        android:layout_width="300dp"
        android:layout_height="100dp"
        android:layout_margin="10dp"
        android:textColor="#ffffff"
        android:textSize="18sp"
        android:textStyle="bold"
        android:background="@drawable/try_shape_3"/>
 </LinearLayout>

 

shape代码:

 

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:shape="rectangle"> 
  4.     <solid android:color="#ff00ff"/> 
  5. </shape> 
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle">
    <solid android:color="#ff00ff"/>
</shape>

对应图形:

 

2、oval(椭圆)

控件代码不变,下面是shape代码:

 

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:shape="oval"> 
  4.     <solid android:color="#ff00ff"/> 
  5. </shape> 
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="oval">
    <solid android:color="#ff00ff"/>
</shape>

对应图形:(控件大小的矩形所对应的椭圆)

 

3、line(线形)

 

没觉得这个能有什么用……,也不讲了,没什么意思

4、ring(环形)

还记得他所特有的几个属性么:

 

  1. android:innerRadius         尺寸,内环的半径。   
  2. android:thickness           尺寸,环的厚度   
  3. android:innerRadiusRatio    浮点型,以环的宽度比率来表示内环的半径,   
  4.       例如,如果android:innerRadiusRatio,表示内环半径等于环的宽度除以5,这个值是可以被覆盖的,默认为9.   
  5. android:thicknessRatio      浮点型,以环的宽度比率来表示环的厚度,例如,如果android:thicknessRatio="2",   
  6.       那么环的厚度就等于环的宽度除以2。这个值是可以被android:thickness覆盖的,默认值是3.   
  7. android:useLevel            boolean值,如果当做是LevelListDrawable使用时值为true,否则为false. 
android:innerRadius         尺寸,内环的半径。  
android:thickness           尺寸,环的厚度  
android:innerRadiusRatio    浮点型,以环的宽度比率来表示内环的半径,  
      例如,如果android:innerRadiusRatio,表示内环半径等于环的宽度除以5,这个值是可以被覆盖的,默认为9.  
android:thicknessRatio      浮点型,以环的宽度比率来表示环的厚度,例如,如果android:thicknessRatio="2",  
      那么环的厚度就等于环的宽度除以2。这个值是可以被android:thickness覆盖的,默认值是3.  
android:useLevel            boolean值,如果当做是LevelListDrawable使用时值为true,否则为false.

这么几个属性无外乎就是定义环形的内环尺寸和环的宽度。

 

举个例子:

控件定义:

 

  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  2.     android:layout_width="match_parent" 
  3.     android:layout_height="match_parent" 
  4.     android:orientation="horizontal" >     
  5.     <TextView 
  6.         android:layout_width="300dp" 
  7.         android:layout_height="100dp" 
  8.         android:layout_margin="10dp" 
  9.         android:textColor="#ffffff" 
  10.         android:textSize="18sp" 
  11.         android:textStyle="bold" 
  12.         android:background="@drawable/try_shape_2"/> 
  13. </LinearLayout> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >    
    <TextView
        android:layout_width="300dp"
        android:layout_height="100dp"
        android:layout_margin="10dp"
        android:textColor="#ffffff"
        android:textSize="18sp"
        android:textStyle="bold"
        android:background="@drawable/try_shape_2"/>
 </LinearLayout>

shape定义:(这里一定要要加上useLevel属性并定义为false,不然没有效果)

 

 

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:shape="ring"  
  4.     android:innerRadius="20dp"  
  5.     android:thickness="50dp"   
  6.     android:useLevel="false"> 
  7.      
  8.     <solid android:color="#ff00ff"/> 
  9.      
  10. </shape> 
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="ring" 
    android:innerRadius="20dp" 
    android:thickness="50dp"  
    android:useLevel="false">
    
    <solid android:color="#ff00ff"/>
    
</shape>

效果图:

 


好啦,这部分就到这了,有关Shape的使用最多的还是第二部分,即当shape为矩形时,结合那几个子标签共同使用时,对于其它的三个Shape平时用到的可能性不大,我这里讲的也不太细致,下面给大家第一部分的源码,直接运行,就能出来一个Shape效果。

Android Studio属性学习(一)——shape属性 一、前提 在这里会讲解shape属性的各个元素,以及效果展示及使用 二、目标 shape 三、内容 1、首先创建一个shape.xml文件以及在布局文件中添加一个按钮用来展示添加属性后的样式 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/... 阅读详情

相关推荐

Android Shape的使用详解

文章目录概念什么是ShapeShape可以用来做什么?Shape的一些基础属性使用 概念 什么是Shape 官方的话来说,这是在 XML 中定义的一般形状。指向 GradientDrawable 的资源指针 Shape可以用来做什么? 快速实现一些基本图形 方型:rectangle,这也是默认的形状 椭圆型/圆:oval 线性:line环: ring,为环的时候还有些针对它才使用的一些属性. 快速实现一些圆角,渐变(线性渐变,径向渐变,扫描渐变),阴影等效果 代替图片设置为View的背景 可以减少a

xzj_2013的专栏 793

Android入门之路 - shape保姆级手册

使用方式: 1.在res - drawable - 创建文件(一般为Shape开头) 2.文件内部shape为最外层标签,可设置当前的shape形状,有圆形,长方形,环形,线形 3.内部6种子条目标签,要熟悉掌握,长方形同时可实现圆化MainActivity :package com.yl.shape.shapedemo;import android.content.Intent; impor

Android、前端、小程序、后端 4667

视觉SLAM十四讲习题答案

阅读《视觉SLAM十四讲》中遇到的问题及习题资源整理,或为原创,或来自网络,如有问题请与我联系,会在第一时间加以修正。 后来自己写完看到另一位写的博客,相形见绌,大家可以互相结合的看。 第一讲 1.线性方程的解:转载自宋洋鹏(youngpan1101),了解线性代数可关注B站3Blue1Brown,以及线性代数,知乎上有其精细笔记。 2.高斯分布参考这位博主Johnny-Cuii的文章,具体...

INFINITE POSSIBILITIES 1万+

Android样式之shape标签(基础)

shape

QG 4033

Oracle 11g RAC 节点通信故障排查与修复指南

本文详细介绍了Oracle 11g RAC集群发生节点通信故障时的系统性排查与修复方法。当出现节点异常重启时,核心问题往往源于心跳网络中断。文章提供了从快速诊断、日志分析到六层深度检查的完整指南,并给出了针对网络配置、内核参数及Oracle已知Bug等常见根因的实战解决方案,帮助DBA快速恢复集群稳定。

weixin_29246195的博客 270

【软件分享】天若OCR文字识别V4.48(翻译功能免费)

软件简介 吾爱破解论坛大佬天若幽心开发的一款OCR文字识别工具。支持快速截图识别,以及文本翻译。 下载地址 蓝奏云盘:点击下载 百度网盘:点击下载(密码:4dm4) 坚果云盘:点击下载 天翼云盘:点击下载 微软云盘:点击下载 使用教程 1、下载后对压缩包进行解压 2、双击天若OCR文字识别.exe 3、发现桌面右下角出现软件图标 4、双击软件图标即可开始截图识别 原帖地址 https://www.52pojie.cn/thread-692917-1-1.html ...

XavierJ的博客 1万+

Android程序Shape使用总结!

在Android程序开发中,我们经常会去用到Shape这个东西去定义各种各样的形状。首先我们了解一下Shape下面有哪些标签,都代表什么意思:solid:填充 android:color指定填充的颜色gradient:渐变 android:startColor和android:endColor分别为起始和结束颜色,android:angle是渐变角度,必须为45的整数倍。另外渐变默认的模式为android:type=“linear”,即线性渐变,

huahaiyi的博客 4434

Greenplum基础

CREATE DATABASE 是 SQL 命令,用于创建一个新的数据库。name 是你要创建的数据库的名称。这个名称是必须的,并且在同一个数据库服务器上必须是唯一的。可选项,OWNER 指定了新数据库的所有者,如果未指定,新数据库的所有者默认是执行该命令的用户。dbowner 是数据库所有者的用户名。可选项,TEMPLATE 指定了用于创建新数据库的模板。在 PostgreSQL 和 GreenPlum 中,通常有一个名为 template1 的默认模板。如果不指定,就会使用这个默认模板。

m0_57697768的博客 1206

Android shape的用法详解

一、什么是Shape属性 在项目中经常会给控件定义背景,有时候有些界面可以叫UI做好,但如何显示的更加的贴近用户,则需要我们客户端去优化。 如果在设置背景Android:background=“图片、颜色”,设置单一的属性并不能带来更好的体验。我们此时就可以使用shape属性作为控件的背景。 shape怎么弄? 1. 在res/drawable下新建一个xml文件; 2. 在代码中引用这个xml文件,引用方式和图片一样。 shape有哪些功能? corners ———-圆角 gradi

Android 领域开发程序员,希望通过写博客的方式不断的总结提升自己,大家共同进步哦! 5786

从零开始安装使用opengauss数据库(高斯数据库)

openGauss(高斯数据库)的环境配置、安装方法、基本使用方法

qq_43764807的博客 1万+

ardupilot开发 --- MavLink 篇

ardupilot开发 --- MavLink 篇

记录老板的每次pua,分享领导每天的毒鸡汤... 4248

Android中shape详解

shape 就是形状,通过它的属性设置来画出一些图形用于控件背景.selector等. 不多说直接进入正题: 一、父节点shape属性值 shape |--android:dither |--android:shape |--rectangle      矩阵(默认) |--oval 椭圆 |--line 直线(必须有stroke来设置线的宽度) |--ring 环

JadeRock的专栏 1067

【OpenCV-Python】——图像处理基础&读写及显示图像&读写及播放视频&灰度图/彩色图/图像通道操作、运算

在Python中,OpenCV使用NumPy数组存储图像,Numpy是使用Python进行数组计算的软件包,提供强大的N维数组对象,支持复杂的广播功能(数组运算),集成了C/C++和Fortran代码工具,支持线性代数、傅里叶变换和随机数等特性,还可作为通用数据的高效多维容器,如在OpenCV中显示图像。Numpy的知识点见数据处理专栏,主要包括数据类型、创建数组、数组形状、索引切片和迭代、数组运算等。作为初学者,里面可能有总结不全,后续深入学习后会改善文章!下次学习图形用户界面!

weixin_51658186的博客 2084

Shape详解

引言 我们在开发中经常会对按钮或者布局等进行一些颜色或者形状方面的设置,这个时候Android为我们提供了使用xml就可以设置的方式----shape。并且使用shape文件可以减少图片资源的应用,减小安装包的大小。 小例子 使用shape画一个圆角的button 第一步,在drawable文件夹下创建文件shape_test.xml shape_test.xml <?xml version...

Dimanche的博客 1万+

基于模型上下文协议(MCP)的可插拔式临床AI工具链Clinical DS研究(下)

本研究深入探讨了医疗AI在临床落地中的核心矛盾,即如何从“模型能答”迈向“系统可信、可用、可追溯”。为解决此矛盾,我们创新性地提出并详细设计实现了一套基于模型上下文协议(MCP)的**“可插拔式临床AI工具链”**架构。通过将复杂的医疗AI系统解构为Host、MCP Server和标准协议三层,并将各类能力(临床决策、影像分析、合规审计)封装为标准的、可独立演进的Server,我们成功地构建了一个模块化、高内聚、低耦合的系统。

AllenLV的博客 1380

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

详解shape标签

一、简单使用 刚开始,就先不讲一堆标签的意义及用法,先简单看看shape标签怎么用。 1、新建shape文件 首先在res/drawable文件夹下,新建一个文件,命名为:shape_radius.xml 内容是这样的:(先不需要理解,先看shape怎么用) &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;shape xmlns:androi...

android开发笔记 667

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

android shape详解

shape,selector,相关汇总 一、通过动画实现 定义res/anim/loading.xml如下: [java] view plaincopy <?xml version="1.0" encoding="UTF-8"?> <animation-list android:oneshot="false" xmlns:android="http://schemas.android.com/apk/res/android"> <item android:duration="150" and

常兴E站 3360

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

android shape java_android shape详解

一、简单使用 刚开始,就先不讲一堆标签的意义及用法,先简单看看shape标签怎么用。 1、新建shape文件 首先在res/drawable文件夹下,新建一个文件,命名为:shapAndroid中常常使用shape来定义控件的一些显示属性,今天看了一些shape的使用,对shape有了大体的了解,稍作总结:先看下面的代码:android:startColor="#ff8c00"android:en...

weixin_39926943的博客 445

shape属性详解使用

前言:(转载:https://www.cnblogs.com/MianActivity/p/5867776.html) 大神勿喷,只为记录 一、简单使用 刚开始,就先不讲一堆标签的意义及用法,先简单看看shape标签怎么用。 1、新建shape文件 首先在res/drawable文件夹下,新建一个文件,命名为:shape_radius.xml 内容是这样的:(先不需要理解,...

LHK_NO的博客 1439

python中shape_基于Python对数据shape的常见操作详解

这一阵在用python做DRL建模的时候,尤其是在配合使用tensorflow的时候,加上tensorflow是先搭框架再跑数据,所以调试起来很不方便,经常遇到输入数据或者中间数据shape的类型不统一,导致一些op老是报错。而且由于水平菜,所以一些常用的数据shape转换操作也经常百度了还是忘,所以想再整理一下。一、数据的基本属性求一组数据的长度a = [1,2,3,4,5,6,7,8,9,10...

weixin_39914868的博客 1484

Android中shape属性详解

一、简单使用 刚开始,就先不讲一堆标签的意义及用法,先简单看看shape标签怎么用。 1、新建shape文件 首先在res/drawable文件夹下,新建一个文件,命名为:shape_radius.xml 内容是这样的:(先不需要理解,先看shape怎么用) <?xml version="1.0" encoding="utf-8"?> <shape xmlns:an...

Jason_Lee155的博客 652

android shape大小,Android shape属性详解

一、概述最近太忙了,几乎每天都在做项目。同时写两个项目的感觉真爽。在我们开发中,会经常遇到shape这种属性,这种属性可以在没有美工的情况照样可以实现我们想要的效果。自动动手,丰衣足食。二、效果图这里写图片描述二、属性shape描述rectangle矩形(默认)oval椭圆line直线ring环形三、基本属性基本属性描述Corners圆角Solid内部填充颜色Gradient渐变色Stroke这是...

weixin_33634886的博客 1295

Shape属性详解

本人复习回忆中,简单的描述一下Shape XML下属性,方便使用。

人生旅途上的一个脚印 1313

Android shape 各种参数 详解

原文章地址:http://blog.youkuaiyun.com/ekeuy/article/details/12349853 在看很多开源代码中都使用到了shape,我看代码的时候一般都一带而过了,没有仔细去研究,这几天刚好有空就顺带详细了解一下,在学习的过程中参考了官方文档和网上的示例代码,本文后面会附上测试代码。          Android应用中使用shape的步骤是这样子的,(1)在

sinat_31820805的博客 1445
上一篇: 6.0新控件:TextInputLayout_TextInputEditText的使用
下一篇: Android中Menu详解
Android_Object
博客等级 码龄10年 1粉丝 14原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值