❶ android:如下关于绘制圆角矩形边框问题,怎么解决
paint.setAntiAlias(true);
尝试在画笔上设置抗锯齿
❷ android 怎么画一个圆弧的正方形
画圆角矩形
建立 rect_gray.xml文件放在drawable文件夹下面。
<shape xmlns:android=""
android:shape="rectangle">
然后在布局的xml里面:
作为ImageView或者Linearlayout等作为背景源就可以了。
<LinearLayout
android:id="@+id/activity_myhezu_wantchuzu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/myhezu_dottedline_rect_green"
android:orientation="horizontal" >
❸ android绘制圆角矩形为什么圆角边粗了
用shapedrawable画一个圆角矩形作为按钮的background,但是圆角的地方总是有点粗,和直接用xml做出来的背景不一样
float[]
outerR = new float[] { 20f, 20f, 20f, 20f, 0, 0, 0, 0 };
Shape shape = new
RoundRectShape(outerR, null, null);
image.setBackgroundDrawable(new
CustomShapeDrawable(shape,0xffea0000));
class CustomShapeDrawable extends
ShapeDrawable {
int color ;
public CustomShapeDrawable(Shape s,int
color) {
super(s);
this.color =
color;
}
@Override
protected void onDraw(Shape shape, Canvas
canvas, Paint paint) {
paint.setStrokeJoin(Join.ROUND);
paint.setDither(true);
paint.setAntiAlias(true);
paint.setStyle(Style.STROKE);
paint.setColor(0xffea0000);
paint.setStrokeWidth(4f);
shape.draw(canvas, paint);
}
}
把paint.setStrokeJoin这行去掉再试试
❹ android怎样在代码中创建shape圆oval
在drawable文件夹中创建bg_oval_shape.xml的xml文件
文件中添加如下代码
<?xmlversion="1.0"encoding="utf-8"?>
<shapexmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid
android:color="#676767"/>
</shape>
3.在需要添加oval的控件中引用,代码如下:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/bg_oval_shape"/>
❺ Android如何画圆角矩形
建立 rect_gray.xml文件放在drawable文件夹下面。
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 填充颜色 -->
<solid android:color="#FFFFFF"></solid>
<!-- 线的宽度,颜色灰色 -->
<stroke android:width="1dp" android:color="#D5D5D5"></stroke>
<!-- 矩形的圆角半径 -->
<corners android:radius="0dp" />
</shape>
然后在布局的xml里面:
作为ImageView或者Linearlayout等作为背景源就可以了。
<LinearLayout
android:id="@+id/activity_myhezu_wantchuzu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/myhezu_dottedline_rect_green"
android:orientation="horizontal" >
❻ android 怎么画一个圆角矩形
有两种方法设置:
一:定义一个xml布局文件,分别设置四个角
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- 背景色 -->
<solid android:color="#FEBB66"/>
<!-- 边框色 -->
<stroke android:width="0.3dip" android:color="#ffffff" />
<!-- 边角:设置圆角大小 -->
<corners android:topLeftRadius="5dp"
android:topRightRadius="5dp"
android:bottomRightRadius="5dp"
android:bottomLeftRadius="5dp"/>
</shape>
二:把上面设置边角的标签属性改成如下
<!-- 边角:设置圆角大小 -->
<corners android:radius="5dp"/>
以上两种效果是一样的。然后引用这个布局文件就好
❼ Android studio圆角矩形的布局如何设计
你可以使用shape定义一个圆角矩形,并将其作为布局的背景即可。
圆角矩形的shape代码如下:
//定义四个圆角 文件名shape_round_corner
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#ff00" />
<corners android:topLeftRadius="12dp"
android:topRightRadius="12dp"
android:bottomRightRadius="12dp"
android:bottomLeftRadius="12dp"/>
<stroke android:width="1dp" android:color="#ff0" />
</shape>
设置背景代码如下:
<LinearLayout
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:alpha="0.8"
android:background="@drawable/shape_round_corner">
</LinearLayout>
❽ android的圆角矩形按钮button如何实现按下按钮颜色会变
android 设置圆角按钮后,按下按钮后,还能改变按钮的颜色
<?xml version="1.0" encoding="UTF-8"?>
<item android:state_pressed="false">
<shape android:shape="rectangle" >
<!-- 填充的颜色 -->
<solid android:color="@color/btn_register_normal"></solid>
<!-- 设置按钮的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<corners android:radius="15dip" />
<!-- padding:Button里面的文字与Button边界的间隔 -->
<padding android:bottom="2dp" android:left="2dp" android:right="2dp" android:top="2dp" />
</shape>
</item>
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="@color/lightblue" />
<corners android:radius="15dip" />
</shape>
</item>
</selector>
2. 圆角有时候需要设置一边是圆角,一边是方形的。
<?xml version="1.0" encoding="utf-8"?>
<corners
android:topLeftRadius="5dp"
android:topRightRadius="5dp"
android:bottomLeftRadius="30dp"
android:bottomRightRadius="30dp"/>
<!-- 这是半透明,还可以设置全透明,那就是白色边框的效果了 -->
<solid android:color="#ff065e8d" />
<stroke
android:dashGap="0dp"
android:width="4dp"
android:color="@android:color/white" />
</shape>
❾ android 圆角样式shape 的shape属性什么意思
shape官方给出了很多属性的解释,如下:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
><!-- 其中rectagle表示矩形,oval表示椭圆,line表示水平直线,ring表示环形 -->
<!-- 节点属性介绍如下 -->
<corners />
<!-- 节点1:corners (圆角)
android:radius 圆角的半径 值越大角越圆
android:topLeftRadius 左上圆角半径
android:topRightRadius 右上圆角半径
android:bottomLeftRadius 左下圆角半径
android:bottomRightRadius 右下圆角半径
-->
<gradient />
<!-- 节点2: gradient (背景颜色渐变)
android:startColor 起始颜色
android:centerColor 中间颜色
android:endColor 末尾颜色
android:angle 渐变角度,必须为45的整数倍。
android:type 渐变模式 默认是linear(线性渐变)radial(环形渐变)
android:centerX X坐标
android:centerY Y坐标
android:gradientRadius radial(环形渐变)时需指定半径
-->
<padding />
<!-- 节点3: padding (定义内容离边界的距离)
android:left 左部边距
android:top 顶部边距
android:right 右部边距
android:bottom 底部边距
-->
<size />
<!-- 节点4:size (大小)
android:width 指定宽度
android:height 指定高度
-->
<solid />
<!-- 节点5:solid (填充)
android:color 指定填充的颜色
-->
<stroke />
<!-- 节点6:stroke (描边)
android:width 描边的宽度
android:color 描边的颜色
把描边弄成虚线的形式"- - -":
android:dashWidth 表示'-'这样一个横线的宽度
android:dashGap 表示之间隔开的距离
-->
</shape></span>
❿ android怎么画圆角的矩形
如果你是在自定义view的onDraw方法中:
java">RectFrectF=newRectF(100,100,500,500);//先画一个矩形
Paintpaint=newPaint(Paint.ANTI_ALIAS_FLAG);//创建画笔
paint.setColor(R.color.colorAccent);//添加画笔颜色
canvas.drawRoundRect(rectF,30,30,paint);//根据提供的矩形为四个角画弧线,(其中的数字:第一个表示X轴方向大小,第二个Y轴方向大小。可以改成其他的,你可以自己体验),最后添加画笔。
如果你是在布局中直接添加,楼上已经做出方法,我就不举例了。