![](/img/trans.png)
[英]My emulator opens as below, but I want it to open in phone view. How can I achieve this?
[英]How can I achieve the view like below image? I want to make the view from xml using Roatation
请帮助我已经喜欢屏幕截图 2 的视图,但在实现屏幕截图 1 时遇到问题。是否可以这样做?
提前致谢。
<?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 或类似的东西来做到这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.