2013-03-27 51 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

相关问题