带有居中位图的Android问题很奇怪

时间:2011-08-26 08:40:23

标签: android xml bitmap

我的应用程序中存在图像问题。 我想有一个标题图像,可以占用我的应用程序的所有宽度。 为此,我创建了一个非常宽的图片,主要对象位于中心, 然后将我的布局中的位图居中。

使用该代码:

<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/header"
    android:gravity="center_horizontal|bottom" />

和那个布局定义:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:fillViewport="true"
    android:background="#ffffff"
    android:layout_gravity="center_horizontal" >

    <LinearLayout
    android:id="@+id/accueil_layout"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#ffffff"
        android:layout_gravity="center_horizontal" >

        <FrameLayout
        android:layout_width="fill_parent"
        android:layout_height="150dip"
        android:background="@drawable/bitmap_header"
        android:layout_weight="1">

        <TextView 
            android:id="@+id/allure"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/txt_allure"
         />

        </FrameLayout>

    <TextView 
        android:id="@+id/slogan"
        android:text="@string/txt_slogan"
         />

这个代码在第一次执行时运行良好。

正如您在此处所见:http://imagebin.org/index.php?mode=image&id=169619

如果我打电话给另一个意图,然后回到那个意图,它仍然会正常显示。

但如果我将另一个Intent称为同一个活动, 很奇怪地显示了这个活动的第二个实例。

如下:http://imagebin.org/index.php?mode=image&id=169620

如同任何人一个想法,关于我如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

我认为必须在FrameLayout下使用TextView做一些事情,因为它不会显示在第二个图片上。也许将FrameLayout更改为RelativeLayout或LinearLayout,看看会发生什么。