zoukankan      html  css  js  c++  java
  • android Shape Drawable美化圆角图形

    ShareDrawable资源

    shareDrawable资料用于定义一个基本的集合图形,它在xml资源文件中,使用<shap.../>根元素定义,使用android:shape属性定义集合图形类形。shareDrawable可以定义矩形,圆形,椭圆形,线形等几种图形。

    下面举个例子:

    在shape_textview.xml文件中:

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <shape xmlns:android="http://schemas.android.com/apk/res/android"
     3     android:shape="rectangle" >
     4     <gradient android:startColor="#FFFF0000"
     5         android:endColor="#80FF00FF"
     6         android:angle="45"/>
     7     
     8     <padding android:left="7dp"
     9         android:top="7dp"
    10         android:right="7dp"
    11         android:bottom="7dp"/>
    12     <corners android:radius="8dp"/>
    13 </shape>

    在main_activity.xml文件中:

     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     android:paddingBottom="@dimen/activity_vertical_margin"
     6     android:paddingLeft="@dimen/activity_horizontal_margin"
     7     android:paddingRight="@dimen/activity_horizontal_margin"
     8     android:paddingTop="@dimen/activity_vertical_margin"
     9     tools:context=".MainActivity" >
    10 
    11     <TextView
    12         android:layout_width="fill_parent"
    13         android:layout_height="wrap_content"
    14         android:background="@drawable/shape_textview"
    15         android:text="@string/hello_world" />
    16 
    17 </RelativeLayout>

    运行结果:

  • 相关阅读:
    os 模块1
    除法
    python基础四(jsonossys andomstring模块、文件、函数)
    python基础三(集合、文件)
    linux下mysql安装
    linux下tomcat安装
    linux系统jdk安装
    python基础二(list,tuple元祖、dic字典,字符串)
    python基础一(安装、变量、循环、git)
    charles抓包
  • 原文地址:https://www.cnblogs.com/SoulCode/p/5452104.html
Copyright © 2011-2022 走看看