上节小空说Button有个重要属性是shape,其实还有个就是selecter。 Selector是背景选择器,主要控制按钮背景的一些变化,比如按下抬起选中状态。 Shape是设置按钮背景的,如圆形,矩形,渐变,圆角等 他们可以单独的用于Button,也可以【selector】内嵌【shape】,实现更多的按钮效果。 他们的优点就是我们自己可以很方便的自定义...
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定义: <?xmlve...
android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="带边框的文本" android:textSize="24pt" android:background="@drawable/border"/> <TextView android:layout_width="match_parent...
(6)size:设置大小; 例如: activity_main.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" > <TextView android:layout_width...
二、基本属性(corners、gradient、padding、size、solid、stroke) 上面给大家简单的讲了下shape标签组的简单使用方法,下面就具体讲讲shape标签里所具有的几个子标签及所具有的属性。 1.corners 代码语言:txt 复制 <corners//定义圆角 android:radius="dimension"//全部的圆角半径 ...
android shape 边界 androidshape圆形 一、概述 Android实现圆角矩形,圆形或者椭圆等图形,一般主要是个自定义View加上使用Xfermode实现的。实现圆角图片的方法其实不少,常见的就是利用Xfermode,Shader。本文直接继承ImageView,使用BitmapShader方法来实现圆形、圆角和椭圆的绘制,等大家看我本文的方法后,其他的类似形状也就都...
shape - rectangle矩形效果图 image 代码 <?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:gravity="center"android:layout_width="match_parent"android:layout_height="match_parent"><TextViewandroid:layout...
<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@drawable/back_shape"android:orientation="vertical"></LinearLayout> ...
android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/shape_rect_gradient_red" /> 再稍微完善一下这个Button。 代码语言:txt 复制 <Button android:layout_width="match_parent" android:layout_height="wrap_content" ...
2、match_parent和wrap_content 按理说这两个属性一目了然,一个是填充布局空间适应父控件,一个是适应自身内容大小。但如果在列表如ListView中,用错了问题就大了。ListView中的getView方法需要计算列表条目,那就必然需要确定ListView的高度,onMesure才能做测量。如果指定了wrap_content,就等于告诉系统,如果我有一万个条...