如何创建比屏幕大的视图? [英] How to create a view that is bigger than the screen?

查看:25
本文介绍了如何创建比屏幕大的视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以创建比屏幕更大的视图?

Is it possible to create a view that is bigger than the screen?

我需要一个宽度大于设备屏幕的视图.我在旋转动画中使用此视图.在旋转过程中,动画视图之前不在屏幕上的部分将变得可见.

I need a view that has a bigger width then the screen of the device. I use this view in a rotation animation. During the rotation the parts that were not on the screen before animating the view will become visible.

有没有办法用android框架实现这个效果?

Is there a way to achieve this effect with the android framework?

更新

我试图将我的父布局设置得比屏幕大得多,并且它正在工作.这会让事情有点不舒服,但它可以工作.现在的下一个问题是我的布局仍然从屏幕的左侧开始.我想不出有什么方法可以让布局在屏幕的左右两边展开.

I tried to set my parent layout much bigger then the screen and it is working. This will make somethings a little bit uncomfortable but it could work. The next problem now is that my layout still starts at the left side of the screen. I can't think of a method to make the layout to expand itself to the left and the right of the screen.

推荐答案

好的,我得到了答案.它不是很好,因为它使用了一个已弃用的 View 类,但它至少适用于我当前的测试屏幕分辨率,明天将测试其他分辨率.

Ok I got an answer. It is not very nice because it uses a deprecated View class but it works at least on my current testing screen resolution other resolutions are tested tomorrow.

我将我想扩展到屏幕之外的视图以这样的绝对布局包装起来:

I wrapped the view that I wanted to expand beyond the screen in an absolute layout like this:

<AbsoluteLayout
  android:layout_width="wrap_content"
  android:layout_height="fill_parent"
  android:layout_alignParentBottom="true">

  <ImageView
     android:id="@+id/content"
     android:layout_width="600dip"
     android:layout_height="420dip"
     android:scaleType="centerCrop"
     android:layout_x="-200dip"
     android:layout_y="60dip"
     android:src="@color/testcolor" />

</AbsoluteLayout>

-200 x 坐标使视图棒偏离屏幕左侧 200dip.如果我为视图设置动画,屏幕外的那些部分将逐渐变得可见.

The -200 x coordinate makes the view stick 200dip out of the left side of the screen. If I'm animating the view those parts that are outside the screen will gradually become visible.

这篇关于如何创建比屏幕大的视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆