2013-02-16 141 views
0

我正在開發我的第一個Android應用程序,並且我想用兩個連續的圖像和一個帶有一些選項卡的TabWidget構建主meno。我正在使用Android 2.3。如何刪除圖像之間的空白區域?

我不知道爲什麼,但在imges之間,它看起來有些空白,看起來很醜陋......我triyng一直在修改paddin和margin但沒有作品......任何人都知道會發生什麼?

這裏是我的代碼:

<?xml version="1.0" encoding="utf-8"?> 

<TabHost 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@android:id/tabhost" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 
    <!-- android:background="#000000" --> 


<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    > 

    <ImageView android:id="@+id/TwiceBar" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/twice_bar" 
     android:scaleType="fitStart" 
     /> 

    <ImageView 
     android:id="@+id/Banner_publicidad" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/banner_publicidad" 
     android:scaleType="fitStart" /> 

    <TabWidget 
     android:id="@android:id/tabs" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 

    <FrameLayout 
     android:id="@android:id/tabcontent" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

    </LinearLayout> 
</TabHost> 

預先感謝您的幫助!

回答

0

調整的位,fitStart只會將圖像移動到圖像視圖的頂部/左側,它不會填滿空間。

cropCenter允許圖像按照您的要求填充空間,因此如果圖像視圖比圖像更寬,這意味着它需要裁剪底部和頂部以填充空間,它會這樣做。

通常,Center scaleTypes最適合用來填充空間。

<LinearLayout 
android:orientation="vertical" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<ImageView android:id="@+id/TwiceBar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:src="@drawable/twice_bar" 
    android:scaleType="centerCrop" 
    /> 

<ImageView 
    android:id="@+id/Banner_publicidad" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:src="@drawable/banner_publicidad" 
    android:scaleType="centerCrop" /> 

<TabWidget 
    android:id="@android:id/tabs" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" /> 

<FrameLayout 
    android:id="@android:id/tabcontent" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

</LinearLayout> 
4

您是否試過在您的ImageView中添加android:adjustViewBounds =「true」?