按钮未完全居中于其父级
我很惊讶,在我 6 个月的 Android 开发时间里我没有注意到这一点。我有一个真实布局,其底部与屏幕/父级的底部对齐。我想在这个相对布局的中心放置一个按钮。我注意到按钮没有完全垂直居中。按钮底部和relativeLayout 底部之间似乎有几个像素。这是相关布局代码:
<RelativeLayout
android:id="@+id/some_layout"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center"
android:layout_alignParentBottom="true"
android:background="#888">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ping">
</Button>
</RelativeLayout>
有什么想法吗?我的targetSDK是2.2及以上。提前致谢。
I am surprised, i did not notice this during my 6 months of development time on Android. I have a realtivelayout whose bottom is aligned to the bottom of the screen/parent. I wanted to place a button at the center of this relativelayout. I notice that the button is not exactly centered vertically. There appears to be couple of pixels between the bottom of the button and that of the relativeLayout. Here's the piece of relevant layout code:
<RelativeLayout
android:id="@+id/some_layout"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center"
android:layout_alignParentBottom="true"
android:background="#888">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ping">
</Button>
</RelativeLayout>
Any ideas? My targetSDK is 2.2 and above. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论