简体   繁体   English

如何实现如下图所示的视图? 我想使用 Roatation 从 xml 中创建视图

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

在此处输入图片说明

Please help I already do like the view like screenshot 2 but having a problem to achieve like screenshot 1.Is it possible to do?请帮助我已经喜欢屏幕截图 2 的视图,但在实现屏幕截图 1 时遇到问题。是否可以这样做?

View with rotation with feel the screen.旋转查看,感受屏幕。 在此处输入图片说明

Thanks in advance.提前致谢。

  <?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>

I should say that what you're trying to accomplish would be best achieved with a background drawable with the shape you want, rather than trying to rotate views to look like this.我应该说,您想要完成的工作最好使用具有您想要的形状的可绘制背景来实现,而不是尝试旋转视图以使其看起来像这样。 It's simply a lot of work and views to achieve something that a basic knowledge in microsoft paint would achieve as well.只需大量的工作和视图即可实现 microsoft Paint 的基本知识也可以实现的目标。

That being said, to get your desired result, you just need to apply the pivot points of the view you're rotating to the top left corner (0, 0), and rotate only 15 degrees in the opposite direction"话虽如此,为了获得您想要的结果,您只需要将您旋转的视图的轴心点应用到左上角 (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" />

You might also need to make the view a bit longer, since the rotation will mean the view doesn't extend to the edge of the screen (due to pythagorean's theorem).您可能还需要使视图更长一点,因为旋转将意味着视图不会延伸到屏幕的边缘(由于勾股定理)。 You could do this by applying a large dp value for the view's width, or by setting the view's scaleX property to 1.5, or something similar.你可以通过为视图的宽度应用一个大的 dp 值,或者通过将视图的 scaleX 属性设置为 1.5 或类似的东西来做到这一点。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我的模拟器打开如下,但我希望它在手机视图中打开。 我怎样才能做到这一点? - My emulator opens as below, but I want it to open in phone view. How can I achieve this? 我想使用内置的 Android 系统 web 视图打开一个 url,如下图所示 - I want to open a url using inbuilt Android system web view like the below image 如何实现这种观点? - How can I achieve this view? 我怎样才能这样一个android xml视图 - How Can I make a android xml view as this 我想裁剪图像,然后输入图像中的视图。 如何使用这种裁剪方式从相机中裁剪图像? - I want to crop an image and type was view in image. How can I crop an image from camera using this type of cropping? 我怎样才能实现CoverFlow视图 - How can i achieve CoverFlow view 我如何实现这种视图?(在列表视图中) - How can i achieve this kind of view??(in List View) 我有这个XML,我想从这个图像视图获取ID - i have this XML and i want to get image from this Image View against id 我有一个图像的网格视图。我正在从中选择一个图像并在 activity2.xml 中显示它。现在我想拖动这个图像视图。如何做到这一点? - I have a grid view of images.I am selecting one image from it and showing it in activity2.xml.Now I want to drag this image view .How to do this? 使用滚动视图进行xml布局时,如何进行时尚的xml布局设计? - How can I make stylish xml layout design when using Scrolling View for xml layout?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM