本文介绍了在Android的微调控制图形的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的第一个(旧)Android应用程序(悬挂计算器 )则呈现出的问题,我无法找到一个解决方案:在部分的微调是显示在不需要的地方透明线微调控制。的图案是这样的:每个其他微调器有这个问题,从第一个开始微调控制项控件。因此,虽然纺纱2,4,6,......有没有多余的线,纺纱1,3,5,......有它们。

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.

我不能直接提供图像:

[...]作为垃圾邮件prevention机制,新  用户不得发表图片。

不过,我可以给你一个链接:

But I can give you a link:

截图所示出的图形微调问题

RES /布局 XML文件看起来是这样的:

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>

我看这个问题,至少从升级Froyo(And​​roid 2.2的)。在早期版本的(至少是Android 1.6的),它不存在。它的不存在的图形布局编辑器在Eclipse,但我看到它运行的应用程序在手机上,并在仿真器 - 这至少是一致和提示一个问题,我被不正确地做事引起; - 。)

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 ;-).

推荐答案

其实我可以重现上Android 2.3的这种行为。不可能在Android 2.2和更低的。

Actually I can reproduce this behavior on Android 2.3. Not possible on Android 2.2 and lower.

这并不重要,如果你将微调在TableLayout或RelativeLayout的关系。同样的问题出现。

It' doesn't matter if you place the Spinner in a TableLayout or RelativeLayout. Same problem there..

只有解决方案,使乘坐的线路是把1px的 - 查看微调的:

Only solution to get ride of the lines was to put a 1px-View between the spinner:

<Spinner android:layout_height="wrap_content" android:id="@+id/spinnerDriver"
    android:layout_width="match_parent" android:layout_below="@id/driverDesc" />

<View android:id="@+id/helper" android:layout_height="1px"
    android:layout_width="match_parent" android:layout_below="@id/spinnerDriver" />

<Spinner android:layout_height="wrap_content" android:id="@+id/spinnerDriver1"
    android:layout_width="match_parent" android:layout_below="@id/helper" />

这实际上是一个非常,非常,非常......丑陋的解决方案,但它为我的作品...

This is actually a very, very, very... ugly solution but it works for me...

这篇关于在Android的微调控制图形的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 01:05