2012-10-01 39 views
1

嗨,我想知道如何将框对齐到android屏幕的底部?我已经将该盒子制作成9patch png图片,并且实际图片和边框之间仍存在一些间隙。谁能帮帮我吗?我的意思是图形布局屏幕上控制图像大小的蓝色边框与实际图像之间存在实际差距。请原谅我的英语。以图形布局对齐图像

这是蓝盒子

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" > 

<ImageView 
    android:id="@+id/background" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentTop="true" 
    android:src="@drawable/background" /> 

<ImageView 
    android:id="@+id/topbar" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:layout_centerHorizontal="true" 
    android:src="@drawable/top_bar" /> 

<ImageView 
    android:id="@+id/imageView2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/topbar" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="95dp" 
    android:src="@drawable/icon_green" /> 

<ImageView 
    android:id="@+id/box" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true" 
    android:layout_marginBottom="23dp" 
    android:src="@drawable/box" /> 

</RelativeLayout> 
+0

请添加完整版式xml –

+0

以下是完整的xml。希望你能帮助:) – akemalFirdaus

+0

你可以添加你当前布局的图片链接。你在最后一个'ImageView'中有'android:layout_marginBottom =“23dp”'。 –

回答

1

XML代码并不完全了解这个问题,但尝试添加

android:adjustViewBounds="true" 

您ImageViews。

而且我看到id为'box'的视图与底部对齐,底部边距为23dp。这将在屏幕底部创建一个空白;)

+0

我会投你一票,但我只有6个声望。 – akemalFirdaus

0

问题解决了家伙。事实上,事实证明盒子在盘旋,因为盒子的宽度在屏幕上我猜太大了。在图形布局切换到更大的屏幕(5.4英寸,之前是4英寸)后,该框位于底部。感谢您的帮助:)好吧,这很愚蠢,对不起,我很新的Android。

+0

在较小的设备上,这不会是解决方案。我认为box(imageview)的解决方案是大型的,缩小的并保留空格是'adjustViewBounds'。 Android开发几乎涵盖了所有设备,屏幕大小等。 –

+0

啊,现在我看到adjustViewBounds是如何工作的,它保持图像的大小不变,而不管屏幕大小是否正确?这一定会派上用场。感谢大脑。 – akemalFirdaus