我希望像这样的Android屏幕上面的trapeziam形状,图片应该动态更改

时间:2016-07-28 09:16:24

标签: android xml shape

enter image description here`

<!-- Colored rectangle-->
<item>
    <shape android:shape="rectangle">
        <size
            android:width="100dp"
            android:height="50dp" />
        <solid android:color="#FAD55C" />
    </shape>
</item>



<!-- These rectangles for the right side -->


<item
    android:top="63dp"
    android:bottom="-40dp"
    android:right="-25dp">
    <rotate
        android:fromDegrees="-42">
        <shape android:shape="rectangle">
            <solid android:color="#ffffff" />
        </shape>
    </rotate>
</item>

`enter image description here

我想让上半部显示的梯形请帮助我制作这个屏幕我将非常感谢这个

1 个答案:

答案 0 :(得分:2)

如果你想要一个矢量drawable:trapezium.xml

<vector android:height="24dp" android:viewportHeight="300.0"
android:viewportWidth="480.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#E03825" android:pathData="M-18.93,275.26l505.01,-264.25l145.36,277.8l-505.01,264.25z"/>
<path android:fillColor="#FF000000"
    android:pathData="M-33.8,289.15L493,3.68"
    android:strokeColor="#000000" android:strokeWidth="14"/>

修改

然后你可以将它放在imageview前面

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.lcimi.myapplication.MainActivity">
    <ImageView
        android:layout_width="match_parent"
        android:src="@drawable/back"/>
    <ImageView
        android:layout_width="match_parent"
        android:src="@drawable/trapezium"
        android:layout_marginTop="15dp"
        android:scaleType="fitXY"
        android:id="@+id/front"
        android:layout_height="300dp" />

</RelativeLayout>

得到像http://imgur.com/a/CMfON

这样的东西