android+布局倾斜,Android中的倾斜或倾斜UI设计
您可以使用Canvas使用Slant top创建自定义视图,然后将其放在textView上,以实现此外观.Code snippet for slant top custom view :-public class SlantView extends View {private Context mContext;Paint paint ;Path path;public SlantView(Cont
您可以使用Canvas使用Slant top创建自定义视图,然后将其放在textView上,以实现此外观.
Code snippet for slant top custom view :-
public class SlantView extends View {
private Context mContext;
Paint paint ;
Path path;
public SlantView(Context ctx, AttributeSet attrs) {
super(ctx, attrs);
mContext = ctx;
setWillNotDraw(false);
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
}
@Override
protected void onDraw(Canvas canvas) {
int w = getWidth(), h = getHeight();
paint.setStrokeWidth(2);
paint.setColor(Color.WHITE);
paint.setStyle(Paint.Style.FILL_AND_STROKE);
paint.setAntiAlias(true);
path = new Path();
path.setFillType(Path.FillType.EVEN_ODD);
path.moveTo(0,0);
path.lineTo(0,h);
path.lineTo(w,h);
path.close();
canvas.drawPath(path, paint);
}
}
有关如何将其与TextView一起使用的代码段
android:layout_width="match_parent"
android:layout_height="30dp"
android:id="@+id/slant_view"
/>
更多推荐
所有评论(0)