【发布时间】:2011-01-21 03:49:39
【问题描述】:
我的活动如下所示
| header |
|------------------|
| ViewGroup |
| that fills |
| the screen |
| |
| centered |
| button |
| |
|------------------|
| footer |
填充屏幕的 View Group 是 RelativeLayout 的子项,RelativeLayout 使用 fill_parent 和 layout_below 页眉和 layout_above 页脚填充屏幕。该RelativeLayout下的ViewGroup在运行时设置为与RelativeLayout相同的宽高。
之所以在运行时设置相同的高度是因为这个视图组可以用手指拖到左边(类似于Android主屏幕)如果我把它拖到左边就可以了。但是如果我把它拖到右边,我的 fill_parent 尺寸就会搞砸。
| header |
|------------------|
| ' ViewGroup | '
| ' that fills| '
| ' the screen| '
| ' | '
| ' centered | <-- button not centered. It is only centered on the visible area, not the whole thing
| ' button | '
| ' | '
| ' | '
|------------------|
| footer |
我进行定位的方式是通过设置 ViewGroup 的左边距将其向右移动(或将其设置为负向左移动)
为什么我不能使用HorizontalScrollView。
这是android的顶视图
' previous ' current ' next ' # Three panes that can be dragged to switch between
| | # The android screen bounderies
我计划让用户能够通过左右拖动屏幕来进入下一个/上一个。如果用户稍微拖动屏幕并且他/她拖得很慢
' previous ' current ' next '
| |
然后屏幕应该动画回到原位
' previous ' current ' next '
| |
如果用户做的很快
' previous ' current ' next '
| |
然后屏幕应该为其余部分设置动画
' previous ' current ' next '
| |
Previous 应该成为新的 current,我们应该有一个新的 previous
' previous ' current ' next '
| |
我使用了滚动视图,我会做这样的事情
' previous ' current ' next '
| |
除非我跳过滚动,否则现在没有空间容纳新的前一个
' previous ' current ' next '
| |
这对我来说听起来更糟。
所以我的选择是
-
AbsoluteLayout(已弃用/不要使用) -
RelativeLayout.LayoutParams.setMargins(见下文。这就是我现在正在做的) - 写我自己的
LayoutManager(听起来比它更容易) - 将像素绘制到屏幕上,而不是使用
Views(DirectDraw 或 OpenGL) HorizontalScrollView
【问题讨论】:
标签: android layout dimensions