[英]Custom drawable angle android
首先,这不是一个重复的问题。 我想使用drawable在android中实现此自定义设计。 如何实现图像中的电弧效果?
到现在为止我做了什么:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<rotate
android:fromDegrees="-5"
android:pivotX="0%"
android:pivotY="100%"
android:toDegrees="50">
<shape android:shape="rectangle">
<solid android:color="@color/light_pink" />
<corners android:bottomLeftRadius="10dp"
android:bottomRightRadius="20dp"/>
</shape>
</rotate>
</item>
<item android:bottom="50dp">
<rotate
android:fromDegrees="0"
android:pivotX="10%"
android:pivotY="-100%"
android:toDegrees="0">
<shape android:shape="rectangle">
<solid android:color="@color/light_pink" />
</shape>
</rotate>
</item>
</layer-list>
问题:图像与背景重叠。 我也将clipChildren设置为父布局,但没有效果。
我的版式
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/top_arc"
android:clipChildren="true">
<ImageView
android:layout_width="match_parent"
android:layout_height="400dp"
android:src="@drawable/no_image_male" />
</RelativeLayout>
</RelativeLayout>
仅供参考:我有相同的SVG,但不知道如何防止重叠。
在这里,您可以找到解决方案。 只需更换颜色即可。
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/top_rl_gradient"/>
<item
android:bottom="-200dp"
android:left="0dp"
android:right="-300dp"
android:top="200dp">
<rotate
android:fromDegrees="-10"
android:pivotX="0%"
android:pivotY="100%">
<shape
android:shape="rectangle">
<solid
android:color="@color/white"/>
</shape>
</rotate>
</item>
您可以通过旋转标签调整可绘制对象的角度和高度。 希望这对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.