2014-10-28 79 views
0

我正在製作一個Android應用程序,我正在使用ImageView.My圖像在普通手機屏幕 上完美顯示,但在大屏幕設備(如Tabs)上,它變得越來越小,在左側屏幕。那麼什麼是最適合相同的解決方案?Android Imageview越來越小

這是我的XML:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <RelativeLayout 
     android:id="@+id/rl" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:background="#550e8c" > 

     <TextView 
      android:id="@+id/textView2" 
      android:layout_width="match_parent" 
      android:layout_height="40dp" 
      android:background="#550e8c" 
      android:text="" 
      android:textColor="#e2ffff" /> 

     <Button 
      android:id="@+id/help" 
      android:layout_width="52dp" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom="@+id/textView2" 
      android:layout_alignParentTop="true" 
      android:layout_alignRight="@+id/textView2" 
      android:background="#550e8c" 
      android:drawableLeft="@drawable/help1" /> 
    </RelativeLayout> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/rl" 
     android:background="#E5E3E4" 
     android:orientation="horizontal" 
     > 

     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/home" 
      android:adjustViewBounds="true" 

/> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_marginBottom="5dp" 
     android:orientation="vertical" > 

     <Button 
      android:id="@+id/button1" 
      android:layout_width="fill_parent" 
      android:layout_height="52dp" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp" 
      android:background="#781a8f" 
      android:drawableLeft="@drawable/earthnew1" 
      android:drawablePadding="30dp" 
      android:gravity="left|center_vertical" 
      android:paddingLeft="10dp" 
      android:text="@string/aware_patient" 
      android:textColor="#e2ffff" 
      android:textStyle="bold" /> 

     <Button 
      android:id="@+id/btnCardiology_updates" 
      android:layout_width="match_parent" 
      android:layout_height="52dp" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp" 
      android:layout_marginTop="6dp" 
      android:background="#781a8f" 
      android:drawableLeft="@drawable/updates1" 
      android:drawablePadding="30dp" 
      android:gravity="left|center_vertical" 
      android:paddingLeft="10dp" 
      android:text="@string/Cardiology_updates" 
      android:textColor="#e2ffff" 
      android:textStyle="bold" /> 

     <Button 
      android:id="@+id/button3" 
      android:layout_width="match_parent" 
      android:layout_height="52dp" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp" 
      android:layout_marginTop="6dp" 
      android:background="#781a8f" 
      android:drawableLeft="@drawable/linknew1" 
      android:drawablePadding="30dp" 
      android:gravity="left|center_vertical" 
      android:paddingLeft="10dp" 
      android:text="@string/useful_links" 
      android:textColor="#e2ffff" 
      android:textStyle="bold" /> 

     <Button 
      android:id="@+id/button4" 
      android:layout_width="match_parent" 
      android:layout_height="52dp" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp" 
      android:layout_marginTop="6dp" 
      android:background="#781a8f" 
      android:drawableLeft="@drawable/linknew1" 
      android:drawablePadding="30dp" 
      android:gravity="left|center_vertical" 
      android:paddingLeft="10dp" 
      android:text="@string/Useful_journlas" 
      android:textColor="#e2ffff" 
      android:textStyle="bold" > 
     </Button> 
    </LinearLayout> 

</RelativeLayout> 
+0

烏爾使用圖像HIGHT和寬度WRAP_CONTENT所以硫雜聯樹脂使用HIGHT和寬度固定像50dp 50dp – 2014-10-28 05:36:18

+0

我認爲你必須爲7和10製作圖像的圖像,並放在各自的可繪製文件夾,如sw600和sw720。 – 2014-10-28 05:37:09

+1

問題可能與解決方案有關。使用高分辨率圖像並放置在xhdpi和xxhdpi可繪製文件夾中。 – Akhil 2014-10-28 05:38:20

回答

0

對於不同的drawable文件夾,您使用的圖像名稱爲主頁same resolution中。

對於支撐平板電腦,請使用large,xlarge限定符。 的Nexus 7大華電國際平板電腦(從技術上講tvdpi,但是從hdpi拍攝圖像)。所以如果你想把Nexus 7的圖片製作一個名爲drawable-large-hdpi的文件夾,並把圖片放在那裏。

現在關於10英寸平板電腦的情況下,他們是xlarge設備和他們的密度可以從mdpi更改爲xhdpi(Nexus 10)。但許多人的分辨率爲1280 * 800,他們是mdpi設備。

創建文件夾繪製這樣

//用於手機

  1. 繪製,MDPI
  2. 繪製,華電國際
  3. 繪製-xhdpi
  4. 繪製-xxhdpi

// 7英寸片劑

  1. 抽拉-大LDPI
  2. 抽拉-大MDPI
  3. 抽拉-大HDPI(爲Nexus 7)

// 10英寸片劑

  1. 抽拉-XLARGE-MDPI
  2. 抽拉-XLARGE-xhdpi(對於關係10)

創建不同的分辨率home.png。這裏是resolution對於整個屏幕列表根據您的要求

  1. 320 X 480適用於mdpi
  2. 480 X 800的華電國際,大LDPI
  3. 600×1024適用於大切片圖像MDPI(7英寸片劑)
  4. 720 X 1280 xhdpi(S3,關係4)
  5. 800 X 1280用於大HDPI,XLARGE-MDPI(關係如圖7所示,其它10英寸 片劑)
  6. 1080×1920爲xxhdpi(S4,S5,關係5)
  7. 2560 X 1600 XLARGE-xhdpi(關係10)
+0

我試過你的解決方案,但問題仍然在10.1」WXGA屏幕設備 – vvv12 2014-10-28 07:00:17

+0

你有創建'drawable-xlarge-mdpi'文件夾和放置圖像尊重'800 X 1280'屏幕尺寸。 – kId 2014-10-28 07:03:31

+0

感謝bro..ur解決方案的工作......再次感謝 – vvv12 2014-10-28 07:10:02

0

您正在使用線性佈局內的圖像視圖,evethough的ImageView的寬度是wrap_content佈局寬度爲fill_parent。更改此爲wrap_content ...

喜歡這個

<LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/rl" 
     android:background="#E5E3E4" 
     android:orientation="horizontal"> 

     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/home" 
      android:adjustViewBounds="true"/> 
    </LinearLayout> 
+0

我試過這個,但問題仍然存在 – vvv12 2014-10-28 05:45:45

0

的問題是,你是把相同的圖像中的每個文件夾中。由於平板電腦和手機具有不同的分辨率,因此您需要不同的分辨率圖像。如果你使用相同的圖像,那麼你將面臨問題的設備之一。

+0

現在我的圖像分辨率是642 * 305 ..可以給我一些想法什麼樣的分辨率是好的設置爲平板電腦..我應該在哪個drwabvle文件夾中放置它。? – vvv12 2014-10-28 06:04:46

+0

你應該有像drawable-xhdpi,drawable-xxhdpi,drawable-xxxhdpi這樣的文件夾。 http://stackoverflow.com/questions/16079588/setting-drawable-folder-to-use-for-different-resolutions – 2014-10-31 01:51:52

0

您需要使用帶有fill_parent或weight選項的線性佈局和圖像視圖,並使用左側,右側,底部和頂部的邊距。所以您的圖像視圖和線性佈局將根據您的屏幕分辨率進行擴展。

+0

只有大屏幕設備的問題.. – vvv12 2014-10-28 06:10:37

+0

使用重量選項。 – 2014-10-28 06:14:42

+0

480 * 800是分辨率爲7的平板電腦..你可以把你的圖像在任何可繪製的文件夾,爲更好地瞭解用戶drwable_xhdpi文件夾 – 2014-10-28 06:20:08