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. 【小程序】微信小程序实现各种特效实例

    写在前面 最近在负责一个微信小程序的前端以及前后端接口的对接的项目,整体上所有页面的布局我都已经搭建完成,里面有一些常用的特效,总结一下,希望对大家和我都能有所帮助 实例1:滚动tab选项卡 先看一下 ...

  2. webservice部署到服务器报错

    System.Net.WebException: 基础连接已经关闭: 发送时发生错误. ---> System.IO.IOException: 从传输流收到意外的 EOF 或 0 个字节. 在 ...

  3. JAVA编码互转(application/x-www-form-urlencoded)

    本质上来说,java.net.UrlEncoder适用于将 String 转换为 application/x-www-form-urlencoded MIME 格式的静态方法 时 ,使用 但!一般情况 ...

  4. c#枚举 获取枚举键值对、描述等

    using System; using System.Collections.Generic; using System.Collections.Specialized; using System.C ...

  5. django使用xlwt导出excel文件

    这里只是mark一下导出的方法,并没有做什么REST处理和异常处理. 维护统一的style样式,可以使导出的数据更加美观. def export_excel(request): # 设置HttpRes ...

  6. 图片与字符串(base64编码)的转化

    package com.demo; import java.util.*; import java.io.*; import sun.misc.BASE64Decoder; import sun.mi ...

  7. 关于AOP装饰函数中的this

    在学习关于JavaScript的装饰者设计模式的过程中,发现其实现方式的关键在于this的使用. 想象一个匿名函数(其实预定义的有名函数也可以,都存在引用),其中的this: // 我们先定义一个匿名 ...

  8. windows server git

    我有一个阿里云,windows server,我想把代码放阿里云 我去做git,只需要安装copssh 下载git https://git-for-windows.github.io/ 下载Copss ...

  9. 原生JS实现淘宝无缝轮播

    <!DOCTYPE html ><html><head><meta http-equiv="Content-Type" content=& ...

  10. php实现伪静态的方法

    mod_rewrite是Apache的一个非常强大的功能,它可以实现伪静态页面.下面我详细说说它的使用方法 1.检测Apache是否支持mod_rewrite 通过php提供的phpinfo()函数查 ...