我想将图片与我的相对布局顶部对齐,然后在水平方向上居中。以下是我使用的代码:
<ImageView
android:id="@+id/collection_image_background"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
但是这段代码并没有生效。我的图片被居中了,但是并没有对齐到相对布局的顶部。我尝试使用 android:scaleType="fitStart"
,但实际上它只是将图像左对齐和上对齐到其父级。
那么,有什么想法可以使图片正确对齐吗?
另外,我忘了提到我是这样设置图片到我的 ImageView
中的:
BitmapFactory.Options o2 = new BitmapFactory.Options();
o2.inTempStorage = new byte[8*1024];
ops = BitmapFactory.decodeStream(cis,null,o2);
ImageView view = (ImageView) findViewById(R.id.collection_image_background);
view.setImageBitmap(ops);
fill_parent
,它起作用了...我不知道为什么之前在代码中没有更改任何其他内容时它不起作用。无论如何,还是谢谢你的回答! - Android-Droid