2014-11-08 98 views
0

我在Eclipse上使用Android開發非常新。Android - ImageView Image Boundaries Bidder then Image

我正在做一個基本的相對佈局,並有一個標題,歡迎信息,圖像,最終文本。在肖像模式下。

圖像似乎是問題所在。當我在2.7英寸的屏幕上時,視圖範圍擴展到左側和右側,這是沒有問題的,但如果我移動到7「或10」視圖,圖像邊界會上下延伸,從而推動文本在頂部,與底部了。所以,現在有白色的空間相當大的份額。

http://imgur.com/GeM4psS這是圖像時,在7-10" 肖像(見藍色邊界推文遠)

http://imgur.com/16JCtSy這是2.7英寸時的圖像,現在綁定推到左側和右側,但不會引起任何問題。

最佳情況下,我希望圖像始終處於這些範圍內。 XML參與其中。沒有Java被改變。感謝任何幫助。謝謝。如果我改變它以適合它伸展圖像,就擡起頭來。

<RelativeLayout xmlns:tools="http://schemas.android.com/tools" 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:gravity="center_horizontal" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
tools:context="cs.play.quotably.MainActivity" > 

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:text="@string/app_name" 
    android:textSize="30sp" /> 

<ImageView 
    android:id="@+id/imageView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_above="@id/textView3" 
    android:layout_below="@id/textView2" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="8dp" 
    android:adjustViewBounds="true" 
    android:contentDescription="@string/fdr" 
    android:scaleType="fitCenter" 
    android:src="@drawable/fdr" /> 

<TextView 
    android:id="@+id/textView2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/textView1" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="8dp" 
    android:gravity="center" 
    android:text="@string/welcome" 
    android:textSize="15sp" /> 

<TextView 
    android:id="@+id/textView3" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="8dp" 
    android:gravity="center" 
    android:text="@string/quote1" 
    android:textSize="15sp" /> 

</RelativeLayout> 

感謝您的任何和所有幫助!

回答

0

你應該試試這個。 將寬度和高度更改爲30dp並且它不是固定值。 只是嘗試不同的值,如40dp和50dp。 一旦你滿足在兩個設備上測試它。 它應該工作

<ImageView 
 
    android:id="@+id/imageView1" 
 
    android:layout_width="30dp" 
 
    android:layout_height="40dp" 
 
    android:layout_above="@id/textView3" 
 
    android:layout_below="@id/textView2" 
 
    android:layout_centerHorizontal="true" 
 
    android:layout_marginTop="8dp" 
 
    android:adjustViewBounds="true" 
 
    android:contentDescription="@string/fdr" 
 
    android:scaleType="fitCenter" 
 
    android:src="@drawable/fdr" />