2013-03-27 64 views
0

我想在我的應用程序的某個屏幕底部留下一張圖片,我終於實現了這一點,但eclipse自動在我的圖片的頂部和底部添加了一個條。我不想這樣,你能幫忙嗎? 如果您需要更多信息,請說:P。圖片廣告

編輯:activity_main.xml中:

`

<ImageButton 
    android:id="@+id/imageButton1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/textView1" 
    android:layout_centerHorizontal="true" 
    android:minHeight="100dp" 
    android:minWidth="100dp" 
    android:src="@drawable/metro" /> 

<ImageButton 
    android:id="@+id/imageButton2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/textView1" 
    android:layout_toLeftOf="@+id/imageButton1" 
    android:minHeight="100dp" 
    android:minWidth="100dp" 
    android:src="@drawable/syllabus" /> 

<ImageButton 
    android:id="@+id/imageButton3" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignTop="@+id/imageButton1" 
    android:layout_toRightOf="@+id/imageButton1" 
    android:minHeight="100dp" 
    android:minWidth="100dp" 
    android:src="@drawable/bus" /> 

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="18dp" 
    android:height="20dp" 
    android:textColor="#FFFFFF" 
    android:width="175dp" /> 

<ImageButton 
    android:id="@+id/imageButton4" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/imageButton1" 
    android:layout_toLeftOf="@+id/imageButton3" 
    android:minHeight="100dp" 
    android:minWidth="100dp" 
    android:src="@drawable/supermarkt" /> 

<ImageButton 
    android:id="@+id/imageButton5" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/imageButton2" 
    android:layout_below="@+id/imageButton2" 
    android:minHeight="100dp" 
    android:minWidth="100dp" 
    android:src="@drawable/restaurants" /> 

<ImageButton 
    android:id="@+id/imageButton6" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignTop="@+id/imageButton4" 
    android:layout_toRightOf="@+id/imageButton4" 
    android:minHeight="100dp" 
    android:minWidth="100dp" 
    android:src="@drawable/geldautomaat" /> 

<ImageButton 
    android:id="@+id/imageButton7" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/imageButton4" 
    android:layout_toLeftOf="@+id/imageButton6" 
    android:minHeight="100dp" 
    android:minWidth="100dp" 
    android:src="@drawable/kaartrome" /> 

<ImageButton 
    android:id="@+id/imageButton8" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/imageButton6" 
    android:layout_alignTop="@+id/imageButton7" 
    android:minHeight="100dp" 
    android:minWidth="100dp" 
    android:src="@drawable/italiaans" /> 

<ImageButton 
    android:id="@+id/imageButton9" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignTop="@+id/imageButton7" 
    android:layout_toLeftOf="@+id/imageButton7" 
    android:minHeight="100dp" 
    android:minWidth="100dp" 
    android:src="@drawable/telefoon" /> 

    <RelativeLayout 
    android:id="@+id/InnerRelativeLayout" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" > 

    <ImageView 
     android:id="@+id/Skyline" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:src="@drawable/skyline" /> 

</RelativeLayout> 

`

+0

如果您發佈現在的代碼,它會更容易幫助。 – MAV 2013-03-27 17:57:35

+0

這是你的意思嗎? – Ide 2013-03-27 18:05:54

回答

0

很難說發生了什麼,如果你沒有你的相關代碼張貼的。

如果您使用ImageView並使用XML編寫佈局,則代碼應如下所示。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="bottom" 
    android:orientation="vertical" > 

    ...other views for the screen... 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_heigth="wrap_content" 
     android:layout_gravity="bottom" 
     android:src="@drawable/some_img" /> 
</LinearLayout> 

假設你正在使用的LinearLayout與垂直方向,這應該圖像添加到佈局,使之正好是寬度的父(如果它的父屏幕是根佈局)和縮放長度適當。 gravity使圖片落在佈局的底部(除非在其下面佈置了某些東西)。

應該根本沒有酒吧。

編輯:代碼現在發佈。 您應該擁有根視圖的XML部分中的所有視圖,例如您的圖像位於底部的RelativeLayout。如果將相對佈局的頭部移動到XML的頂部並將xmlns:android="http://schemas.android.com/apk/res/android"添加到該頂部,圖像應該完全按照你想要的來做。標題應該看起來像這樣並且位於XML文件的頂部。

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/InnerRelativeLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

你有沒有通過android developer tutorials?他們非常有幫助。

+0

我的意思是,當它不僅僅顯示圖片,而且它的頂部和底部還有一個條紋,你知道如何解決這個問題嗎? – Ide 2013-03-27 18:17:53

+0

您確定這些不只是編輯器行來調整圖像大小或表明其對齊?您是使用純eclipse還是與Android SDK包一起打包的eclipse? – Jaws212 2013-03-27 18:20:08

+0

我正在使用封裝的eclipse,我不認爲它是編輯器,因爲我可以通過在#000000屬性中更改背景使它們變黑。 – Ide 2013-03-27 18:26:13

相關問題