[英]Custom drawable angle android
First of all this is not a duplicate question. 首先,这不是一个重复的问题。 I want to achieve this custom design in android using drawable.
我想使用drawable在android中实现此自定义设计。 How to achieve the arc effect as in the image??
如何实现图像中的电弧效果?
Till now what i have done: 到现在为止我做了什么:
<?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>
Issue: The image is overlapping the background. 问题:图像与背景重叠。 I have also set clipChildren to the parent layout but no effects.
我也将clipChildren设置为父布局,但没有效果。
My Layout 我的版式
<?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>
Just for info: I have SVG for the same but don't know how to prevent overlapping. 仅供参考:我有相同的SVG,但不知道如何防止重叠。
Here you go with the solution. 在这里,您可以找到解决方案。 Just replace the colours.
只需更换颜色即可。
<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>
You can adjust the angle and the height of the drawable form the rotate tag. 您可以通过旋转标签调整可绘制对象的角度和高度。 Hope this helps you.
希望这对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.