shape_oval

 <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" > <solid android:color="#ff66aa" /> <stroke
android:width="1dp"
android:color="#ffaaaaaa" /> </shape>

默认矩形

 <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" > <solid android:color="#ffdd66" /> <stroke
android:width="1dp"
android:color="#ffaaaaaa" /> <corners
android:bottomLeftRadius="10dp"
android:bottomRightRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp" /> </shape>

xml

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"> <View
android:id="@+id/v_content"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_margin="20dp" /> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"> <Button
android:id="@+id/btn_rect"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="圆角矩形背景"
android:textColor="#000000"
android:textSize="17sp" /> <Button
android:id="@+id/btn_oval"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="椭圆背景"
android:textColor="#000000"
android:textSize="17sp" /> </LinearLayout> </LinearLayout>

java

 package com.example.alimjan.hello_world;

 import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button; /**
* Created by alimjan on 7/1/2017.
*/ public class class__2_4_3 extends AppCompatActivity implements View.OnClickListener { private View v_content; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.code_2_4_3);
v_content = (View) findViewById(R.id.v_content); Button btn_rect = (Button) findViewById(R.id.btn_rect);
Button btn_oval = (Button) findViewById(R.id.btn_oval);
btn_rect.setOnClickListener(this);
btn_oval.setOnClickListener(this);
} @Override
public void onClick(View v) {
if (v.getId() == R.id.btn_rect) {
v_content.setBackgroundResource(R.drawable.shape_rect_gold);
} else if (v.getId() == R.id.btn_oval) {
v_content.setBackgroundResource(R.drawable.shape_oval_rose);
}
} public static void startHome(Context mContext) {
Intent intent = new Intent(mContext, class__2_4_3.class);
mContext.startActivity(intent);
} }

1、shape 有四种类型

  rectangle  矩形

  oval    椭圆(corners属性失效)

  line    直线(必须设置stroke属性)

  ring    圆环

2、corners

  bottomLeftRadius:左下角

  bottomRightRadius:右下角

  topLeftRadius:左上角

  topRightRadius:右上角

3、gradien(颜色渐变)

  linear:线性渐变

  radial:放射渐变

  sweep:滚动渐变

4、padding   间隔大小

5、size  图形尺寸大小

6、solid  内部填充颜色

7、stroke 四周变现

  color:

  dashGap:每段虚线之间间隔

  dashWidth:每段虚线宽度

  width:描边的厚度

Android 开发笔记___shape的更多相关文章

  1. Android开发笔记:打包数据库

    对于数据比较多的控制一般会加入SQLite数据库进行数据存储,在打包时这些数据库是不自动打包到apk中的,如何创建数据库呢 方法1:将创建数据库的sql语句在SQLiteHelper继承类中实现,在第 ...

  2. Android开发笔记--hello world 和目录结构

    原文:Android开发笔记--hello world 和目录结构 每接触一个新东西 都有一个hello world的例子. 1.新建项目 2.配置AVD AVD 没有要新建个,如果不能创建 运行SD ...

  3. 【转】Android开发笔记(序)写在前面的目录

    原文:http://blog.csdn.net/aqi00/article/details/50012511 知识点分类 一方面写写自己走过的弯路掉进去的坑,避免以后再犯:另一方面希望通过分享自己的经 ...

  4. [APP] Android 开发笔记 003-使用Ant Release 打包与keystore加密说明

    接上节 [APP] Android 开发笔记 002 5. 使用ant release 打包 1)制作 密钥文件 release.keystore (*.keystore) keytool -genk ...

  5. [APP] Android 开发笔记 002-命令行创建默认项目结构说明

    接上节:[APP] Android 开发笔记 001 4. 默认项目结构说明: 这里我使用Sublime Text 进行加载.

  6. Android开发笔记——以Volley图片加载、缓存、请求及展示为例理解Volley架构设计

    Volley是由Google开源的.用于Android平台上的网络通信库.Volley通过优化Android的网络请求流程,形成了以Request-RequestQueue-Response为主线的网 ...

  7. Android开发笔记(一百三十四)协调布局CoordinatorLayout

    协调布局CoordinatorLayout Android自5.0之后对UI做了较大的提升.一个重大的改进是推出了MaterialDesign库,而该库的基础即为协调布局CoordinatorLayo ...

  8. 【转】Android开发笔记——圆角和边框们

    原文地址:http://blog.xianqu.org/2012/04/android-borders-and-radius-corners/ Android开发笔记——圆角和边框们 在做Androi ...

  9. 《ArcGIS Runtime SDK for Android开发笔记》

    开发笔记之基础教程 ArcGIS Runtime SDK for Android 各版本下载地址 <ArcGIS Runtime SDK for Android开发笔记>——(1).And ...

随机推荐

  1. Maven仓库搜索jar包依赖网址

    可在该网站搜索jar包依赖 http://search.maven.org/

  2. eclipse通过maven构建web项目步骤说明

    1.  File -> New -> Other ,搜索maven,选择Maven Project,点击Next 2.这里不需要改继续Next 3.这里需要注意,需要选择maven-arc ...

  3. EXIT_SUCCESS EXIT_FAILURE

    在vc++6.0下头文件stdlib.h中定义如下: /* Definition of the argument values for the exit() function */ #define E ...

  4. Object.defineProperty()方法的用法详解

    Object.defineProperty()函数是给对象设置属性的. Object.defineProperty(object, propertyname, descriptor); 一共有三个参数 ...

  5. Linux入门之常用命令(9)进程及端口查看

    [Linux下查看进程] 查看程序对应进程号:ps –ef|grep 程序名 查看进程占用端口:ss -pl | grep 进程号 [通过进程查看端口] 查看占用的端口号:netstat –nltp| ...

  6. Vue状态管理vuex

    前面的话 由于多个状态分散的跨越在许多组件和交互间各个角落,大型应用复杂度也经常逐渐增长.为了解决这个问题,Vue提供了vuex.本文将详细介绍Vue状态管理vuex 引入 当访问数据对象时,一个 V ...

  7. ArcGIS RunTime SDK for Android之Features and graphics

    今天是我开通博客园的第一天,希望以后可以多在博客园上分享自己的学习心得,记录自己的学习历程.最近在学习ArcGIS RunTime SDK for Android,所以第一篇随笔就从这里来吧.官网的教 ...

  8. FastDFS的安装步骤

    1.安装相关环境 yum install -y gcc-c++ yum -y install libevent yum install -y pcre pcre-devel yum install - ...

  9. 从头编写 asp.net core 2.0 web api 基础框架 (2)

    上一篇是: http://www.cnblogs.com/cgzl/p/7637250.html Github源码地址是: https://github.com/solenovex/Building- ...

  10. windows访问控制列表 --ACL(Access Control List)

    1.定义 ACL是一个windows中的表示用户(组)权限的列表. Access Control List(ACL) Access Control Entry(ACE) ... 2.分类 ACL分为两 ...