定位 Android UI
基本上我正在开发与此类似的用户界面:
http://ivitto.files.wordpress.com/2008/09/tap-tap-home.jpg?w=160&h=240
其中存储了一系列按钮线性布局。我的问题是,目前它们沿 x 轴和 y 轴居中,因此它们位于屏幕中间,而不是如图所示位于屏幕的下半部分。我能得到我想要的工作的唯一方法是添加 100px 左右的“顶部填充”,但当然,所需的像素数量完全随屏幕分辨率而变化。虽然这个 100 像素对于 480x320 屏幕来说已经足够了,但对于 1024x600 屏幕来说就太小了。所以基本上我问如何在其父级的底部对齐我的线性布局(另一个线性布局)
Basically I'm developing a user interface similar to this:
http://ivitto.files.wordpress.com/2008/09/tap-tap-home.jpg?w=160&h=240
Where there are a series of buttons stored in a linear layout. My problem is at the moment they are centered along the x axis and the y axis so they are in the middle of the screen rather than in the lower half of the screen as in the image. The only way I can get what I want to work is by adding 100px or so "top padding" but of course the amount of pixels required is entirely variable on the screen resolution. Whilst this 100px is fine for a 480x320 screen it is far too small for a 1024x600 screen. So basically I'm asking how can I align my linear layout at the bottom of its parent (another linear layout)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过将线性布局的重力参数设置为底部?
Have you tried setting the gravity parameter of the linearlayout to bottom ?
是的,尝试重力底部。
顺便说一句。您可以使用“dip”(密度独立像素(http://developer. android.com/guide/practices/screens_support.html#desired-independence ))而不是 px 进行填充。虽然在这种情况下设置重力肯定是更好的方法......
Yes, try gravity bottom.
And by the way. You can use "dip" (density independent pixel ( http://developer.android.com/guide/practices/screens_support.html#density-independence ))instead of px for the padding. Although setting the gravity is surely the nicer way in this case...