1

私は最初の Android アプリケーションを開発しています。2 つの連続した画像を含むメイン メニューと、いくつかのタブを含む TabWidget を構築したいと考えています。Android2.3を使用しています。

理由はわかりませんが、画像の間に、見苦しい空白が表示されます...パディンとマージンを常に変更しようとしていますが、うまくいきません...誰でも何が起こるか知っていますか?

これが私のコードです:

<?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>

よろしくお願いします。

4

2 に答える 2

6

android:adjustViewBounds="true" を ImageViews に追加してみましたか?

于 2013-02-16T18:39:19.803 に答える
0

少し調整fitStartすると、画像が画像ビューの上部/左側に移動するだけで、スペースがいっぱいになりません。

cropCenter要求する方法で画像がスペースを埋めることができるようにします。したがって、画像ビューが画像よりも広い場合、つまり、スペースを埋めるために下部と上部を切り取る必要がある場合は、そうします。

一般に、CenterscaleTypes はスペースを埋めるために使用するのに最適です。

<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>
于 2013-02-16T18:09:04.160 に答える