这样的事情:
我怎样才能实现这一目标?请帮忙
解决方法 最简单的方法是用偏斜切割制作背景图像.如果您希望拥有动态布局并且想要真正剪切小部件,请使用Canvas.saveLayer / restore.像这样:private Paint paint = new Paint(Paint.ANTI_AliAS_FLAG);private Xfermode pdMode = new PorterDuffXfermode(PorterDuff.Mode.CLEAR);private Path path = new Path();protected voID dispatchDraw(Canvas canvas) { int saveCount = canvas.saveLayer(0,getWIDth(),getHeight(),null,Canvas.ALL_SAVE_FLAG); super.dispatchDraw(canvas); paint.setXfermode(pdMode); path.reset(); path.moveto(0,getHeight()); path.lineto(getWIDth(),getHeight() - TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,50,getResources().getdisplayMetrics())); path.close(); canvas.drawPath(path,paint); canvas.restoretoCount(saveCount); paint.setXfermode(null);}
要点:https://gist.github.com/ZieIony/8480b2d335c1aeb51167
<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" xmlns:app="http://schemas.androID.com/apk/res-auto" xmlns:tools="http://schemas.androID.com/tools" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:orIEntation="vertical" app:layout_behavior="@string/appbar_scrolling_vIEw_behavior" tools:showIn="@layout/activity_main"> <com.example.marcin.splitlayout.CutLayout androID:layout_wIDth="match_parent" androID:layout_height="wrap_content"> <ImageVIEw androID:scaleType="centerCrop" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:src="@drawable/mazda" /> </com.example.marcin.splitlayout.CutLayout> <TextVIEw androID:layout_margin="16dp" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:text="Mazda 3" /></linearLayout>
顺便说一句.这个东西最近很受欢迎:)
总结以上是内存溢出为你收集整理的android – 自定义视图,使用不同的子视图对角分割布局全部内容,希望文章能够帮你解决android – 自定义视图,使用不同的子视图对角分割布局所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)