首先,这不是一个重复的问题。我想在android中使用drawable实现这个自定义设计。如何在图像中实现弧效?
直到现在我做了什么:
<?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>
您可以调整旋转标签的可绘制形式的角度和高度。希望这对你有所帮助。