幫助!安卓圖片位置錯誤
我有一個奇怪的問題。我正在編寫一個Android應用程序,允許用戶選擇要在下一頁使用的圖像。這一切都很好,但是當我做了
imageView.setImageBitmap(bitmap);
顯示的新形象,但基本上垂直居中在頁面上,躲在我放置在頁面上在設計時按鈕。佈局是這樣的:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/jeepfront" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imageView"
android:layout_centerHorizontal="true"
android:layout_marginTop="46dp"
android:text="Button" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/button1"
android:layout_centerHorizontal="true"
android:layout_marginTop="43dp"
android:text="Picture resized/cropped with any buttons"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
如果我不叫setBitmap,那麼默認的圖片(@繪製/ jeepfront)顯示就好了,在頁面的頂部,我可以看到按鈕。
任何想法?我在Android上是一個新手,但從1.0開始使用Java。
謝謝, 大衛
由於您沒有提供任何有關位圖的信息,我只能假設它的寬度和高度(縮放版本)比吉普的更大,導致隱藏按鈕以及屏幕背後的文本視圖,重新放置在圖像下方。 – Onik