开发者

Unwanted space between two ImageView on android

Im using this Layout to put two ImageViews one next to the other, but the two images seems to be separated by 1 transparent pixel space.

The blue background is there to make easier to observe the problem...

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#0000FF">
    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_marginTop="5dip">
        <ImageView
            android:src="@drawable/i_position_icon"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
        <ImageView
            android:src="@drawabl开发者_JAVA百科e/i_position_seekbar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
    </LinearLayout>
</LinearLayout>

The .java is:

public class MainActivity extends Activity {

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.main);

    }
}

Im using a device with android 2.2.

I wasnt able to reproduce the glitch on a 2.1-update1 emulator neither on a 1.6 emulator...

Ive checked the images and they have no extra pixels arround them.

Also i tried adding a red 1px width border on the images separately and the glitch is still there, so the images dont seem to be the problem.

These are the problematic images (correctly shown here):

Unwanted space between two ImageView on android

Unwanted space between two ImageView on android

http://dl.dropbox.com/u/7024937/i_position_icon.png

http://dl.dropbox.com/u/7024937/i_position_seekbar.png

And this is what i see in my device:

Unwanted space between two ImageView on android

Thanks.


Sounds strange because I use the same technique in my project and everything seems to be OK. Do you put your drawables into the correct drawable folder. I mean that you should put your images in drawable-hdpi folder if your device has hdpi screen. Sorry, but it's the only thought that came into my mind.


strange, what version SDK are you targeting? i copied your layout and code and made a new project with api level 3 (1.5) and tested it on a 1.5 and 2.2 emulator. On both it worked fine without any spacing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜