如何实现如下图所示的视图?我想使用旋转从 xml 制作视图

How can I achieve the view like below image? I want to make the view from xml using Roatation

请帮助我已经喜欢屏幕截图 2 的视图,但在实现屏幕截图时遇到问题 1.Is 可以吗?

旋转观看,感受屏幕。

提前致谢。

  <?xml version="1.0" encoding="utf-8"?>
   <RelativeLayout     xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/accent_material_dark"
android:orientation="vertical">

<View
    android:id="@+id/header"
    android:layout_width="wrap_content"
    android:layout_height="120dp"
    android:background="#FFFFFF" />

<View
    android:id="@+id/body"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:layout_below="@id/header"
    android:rotation="165"
    android:background="@color/accent_material_dark" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@id/header"
    android:layout_alignParentRight="true"
    android:src="@drawable/ic_action_search"
    android:layout_marginBottom="-32dp"
    android:layout_marginRight="20dp">

</android.support.design.widget.FloatingActionButton>

   </RelativeLayout>

我应该说,您要实现的目标最好是使用具有您想要的形状的可绘制背景来实现,而不是尝试旋转视图以使其看起来像这样。要达到 Microsoft Paint 的基本知识也能达到的效果,这只是大量的工作和观点。

也就是说,要获得所需的结果,您只需将要旋转的视图的轴心点应用到左上角 (0, 0),然后沿相反方向仅旋转 15 度“

<View
    android:id="@+id/body"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:layout_below="@id/header"
    android:transformPivotX="0dp"
    android:transformPivotY="0dp"
    android:rotation="-15"
    android:background="@color/accent_material_dark" />

您可能还需要使视图更长一些,因为旋转意味着视图不会延伸到屏幕边缘(由于毕达哥拉斯定理)。您可以通过为视图的宽度应用较大的 dp 值,或将视图的 scaleX 属性 设置为 1.5 或类似值来实现。