Android 中旋转控件的图形问题
我的第一个(旧)Android 应用程序 (暂停计算器) 正在显示我找不到解决方案的问题:某些微调器上的微调器控件在不需要的位置显示透明线。模式是这样的:从第一个微调器控件开始,所有其他微调器都遇到此问题。因此,虽然旋转器 2、4、6... 没有多余的线条,但旋转器 1、3、5... 却有多余的线条。
下图(下面的链接)首先显示处于选定状态的微调器,然后显示红色分隔符后处于未选定状态的微调器。在选定状态下,除了按钮文本所在的某些位置之外,透明线位于整个控件的基线高度。未选择状态下略有不同。
我无法直接提供图像:
[...] 作为垃圾邮件预防机制,新 不允许用户发布图像。
但我可以给你一个链接:
XML res/layout
下的文件如下所示:
<ScrollView ...>
<TableLayout ...>
<TableRow>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/units"
android:gravity="center_vertical"
android:paddingRight="5dp"
/>
<Spinner
android:id="@+id/unit_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"
/>
</TableRow>
...
</TableLayout>
</ScrollView>
至少从 Froyo (Android 2.2) 开始我就看到了这个问题。在早期版本(至少 Android 1.6)中,它不存在。它不在 Eclipse 的图形布局编辑器中,但我看到它在手机和模拟器中运行应用程序 - 这至少是一致的,并暗示了我因没有正确执行操作而导致的问题;-)。
My first (old) Android app (Suspension Calculator) is showing a problem I cannot find a solution for: the spinner control on some spinners is showing transparent lines in unwanted places. The pattern is this: every other spinner is having this problem, starting with the first spinner control. So while spinners 2, 4, 6, ... have no unwanted lines, spinners 1, 3, 5, ... have them.
The following image (link below) shows the spinner in selected state first, and in unselected state after the red separator. In selected state, the transparent line is at baseline height for the entire control except some places where the button text can be. It's a little different in unselected state.
I cannot provide an image directly:
[...] as a spam prevention mechanism, new
users aren't allowed to post images.
But I can give you a link:
Screenshot that illustrated the graphical spinner problem
The XML file under res/layout
looks like this:
<ScrollView ...>
<TableLayout ...>
<TableRow>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/units"
android:gravity="center_vertical"
android:paddingRight="5dp"
/>
<Spinner
android:id="@+id/unit_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"
/>
</TableRow>
...
</TableLayout>
</ScrollView>
I see this problem at least since Froyo (Android 2.2). In earlier versions (at least Android 1.6), it wasn't there. It's not there in the Graphical Layout editor in Eclipse, but I see it running the application on the phone and in the emulator - that's at least consistent and hints to a problem I'm causing by not doing things right ;-).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上我可以在 Android 2.3 上重现这种行为。在 Android 2.2 及更低版本上不可能。
将 Spinner 放置在 TableLayout 还是RelativeLayout 中都没有关系。同样的问题。
唯一的解决方案是在旋转器之间放置一个 1px-View:
这实际上是一个非常、非常、非常...丑陋的解决方案,但它对我有用...
Actually I can reproduce this behavior on Android 2.3. Not possible on Android 2.2 and lower.
It' doesn't matter if you place the Spinner in a TableLayout or RelativeLayout. Same problem there..
Only solution to get ride of the lines was to put a 1px-View between the spinner:
This is actually a very, very, very... ugly solution but it works for me...