<!--背景颜色渐变 -->
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:startColor="#c0000000" android:endColor="#c0000000"
android:angle="90" /><!--背景颜色渐变 -->
<solid android:color="#00ffffff" /><!-- 背景的填充颜色 -->
<stroke android:width="3dp" color="#ff000000" /><!-- 描边,width是边得宽度,color是颜色 -->
<corners android:radius="10dp" /><!-- 边角圆弧的半径 -->
<padding
android:left="3dp"
android:top="3dp"
android:right="3dp"
android:bottom="3dp" /><!-- 四周留出来的空白 -->
</shape>
给不同的view设置shape,可以实现边白和圆角的效果,类似于系统自带的对话框!
就是自定义实现和系统自带相同效果的view。
例如:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/rounded_menu_out">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/rounded_ignore">
<GridView android:id="@+id/menu_more_window"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numColumns="4"
android:stretchMode="columnWidth"
android:gravity="center" />
</LinearLayout>
</LinearLayout>
其中rounded_menu_out就是外面的边框,rounded_ignore就是定义里面的样式!
跟大家分享一个别人做的例子,声明:是别人做的,谢谢作者分享!
相关推荐
Android shape 属性深入用法 我的博客:http://blog.csdn.net/xiaoyuan511
本文实例讲述了Android编程使用自定义shape实现shadow阴影效果的方法。分享给大家供大家参考,具体如下: 直接上xml文件, 并且附上相应的解析: <?xml version=1.0 encoding=utf-8?> <selector xmlns:android...
android XML Graphics_shape使用方法 可以帮你打造更好的android界面
Android控件系列之Shape使用方法,需要的朋友可以参考一下
ShapeDrawable是一种很常见的Drawable,可以理解为通过颜色来构造的图形,它既可以是纯色的图形,也可以是具有... android:shape=[rectangle> <corners android:radius=integer android:topLeftRadius=integer
shape和selector是Android UI设计中经常用到的,比如我们要自定义一个圆角Button,点击Button有些效果的变化,就要用到shape和selector。可以这样说,shape和selector在美化控件中的作用是至关重要的。 1:Selector ...
shape和selector是Android UI设计中经常用到的,...使用的方法: Java代码中:R.drawable.文件的名称 XML中:android:background=”@drawable/文件的名称” 属性: <shape> android:shape=[“rectangle” | “oval” |
shape和selector是Android UI设计中经常用到的,比如...使用的方法: Java代码中:R.drawable.文件的名称 XML中:android:background=”@drawable/文件的名称” 属性: <shape> android:shape=[“rectangle” |
本文实例讲述了Android使用shape使组件呈现出特殊效果的方法。分享给大家供大家参考,具体如下: 使用到的布局文件 <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=...
本例知识点:Dialog透明,圆角,及GridView的简单用法。 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > ...
当然除了使用drawable这样的图片外今天Android开发网谈下自定义图形shape的方法,对于Button控件Android上支持以下几种属性shape、gradient、stroke、corners等。 我们就以目前系统的Button的selector为例说下: ...
1.背景选择器(位于res/drawable/,使用方法:android:background=”@drawable/XXX”) 代码如下: <?xml version=”1.0″ encoding=”utf-8″?> <selectorxmlns android=”...
主要介绍了Android中实现毛玻璃效果的3种方法,本文讲解了使用系统提供的方法、自定义的方法、C语言实现方法等3种方法,需要的朋友可以参考下
DevShapeUtils开源库 > 项目初衷: 公司项目样式文件n 1个,多人开发文件命名各种各样,每次都要搜索半天...2.1 Android Studio导入方法,添加Gradle依赖 在项目的 build.gradle 添加: android { defaultConfig { ...