2014-09-03 67 views
0

我有一個menuscreen XML。當我打開項目寬屏幕它不適應所有屏幕大小。我怎樣才能克服這個問題。我的項目不支持多設備屏幕視圖

當我想添加關於這個問題的圖片,我想我需要10個代表。點:)

任何人都可以幫助我嗎?

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/ScrollView1" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true" > 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <Button 
      android:id="@+id/samsun" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@drawable/selector" 
      android:text="@string/samsun" 
      android:textColor="#FFFF" /> 

     <Button 
      android:id="@+id/trabzon" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@drawable/selector" 
      android:text="@string/trabzon" 
      android:textColor="#FFFF" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <Button 
      android:id="@+id/adana" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@drawable/selector" 
      android:text="@string/adana" 
      android:textColor="#FFFF" /> 

     <Button 
      android:id="@+id/antalya" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@drawable/selector" 
      android:text="@string/antalya" 
      android:textColor="#FFFF" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <Button 
      android:id="@+id/izmir" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@drawable/selector" 
      android:padding="10dp" 
      android:text="@string/izmir" 
      android:textColor="#FFFF" /> 

     <Button 
      android:id="@+id/bursa" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@drawable/selector" 
      android:padding="10dp" 
      android:text="@string/bursa" 
      android:textColor="#FFFF" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <Button 
      android:id="@+id/istanbul1" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@drawable/selector" 
      android:padding="10dp" 
      android:text="@string/gayrettepe" 
      android:textColor="#FFFF" /> 

     <Button 
      android:id="@+id/istanbul2" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@drawable/selector" 
      android:padding="10dp" 
      android:text="@string/acibadem" 
      android:textColor="#FFFF" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <Button 
      android:id="@+id/erzurum" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@drawable/selector" 
      android:padding="10dp" 
      android:text="@string/erzurum" 
      android:textColor="#FFFF" /> 

     <Button 
      android:id="@+id/diyarbakir" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@drawable/selector" 
      android:padding="10dp" 
      android:text="@string/diyarbakir" 
      android:textColor="#FFFF" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <Button 
      android:id="@+id/ankara" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@drawable/selector" 
      android:padding="10dp" 
      android:text="@string/ankara" 
      android:textColor="#FFFF" /> 

     <Button 
      android:id="@+id/kayseri" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@drawable/selector" 
      android:padding="10dp" 
      android:text="@string/kayseri" 
      android:textColor="#FFFF" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <Button 
      android:id="@+id/alcatel" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@drawable/selector" 
      android:padding="10dp" 
      android:text="@string/alcatel" 
      android:textColor="#FFFF" /> 

     <Button 
      android:id="@+id/huawei" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@drawable/selector" 
      android:padding="10dp" 
      android:text="@string/huawei" 
      android:textColor="#FFFF" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="horizontal" > 

     <Button 
      android:id="@+id/backbone" 
      android:layout_width="fill_parent" 
      android:layout_height="150dp" 
      android:background="@drawable/selector" 
      android:padding="10dp" 
      android:text="@string/backbone" 
      android:textColor="#FFFF" /> 



    </LinearLayout> 
</LinearLayout> 

+1

是的,只是後一個HTML鏈接到圖片,這將有助於配發!您只需要代表將圖片嵌入到您的消息中。 – Chris 2014-09-03 12:38:08

+0

@Mustafa,你可以嘗試回答http://stackoverflow.com/questions/21329127/icon-resolution-constrains-for-android/21330125#21330125 – Jeba 2014-09-03 13:21:39

回答

0

聲明你的尺寸值小,價值觀大,價值觀等XLARGE

不要忘了在AndroidManifest.xml中

<supports-screens 
     android:smallScreens="true" 
     android:normalScreens="true" 
     android:largeScreens="true" 
     android:xlargeScreens="true" 
     android:anyDensity="true"/> 
宣佈支持屏

有關更多信息,請參閱http://developer.android.com/guide/practices/screens_support.html

+0

thansk非常感謝 – 2014-09-03 14:35:25

1

在android中,爲了支持儘可能多的設備,您可以提供一個佈局的多個定義。首先,您需要將這些文件夾添加到資源中,併爲每個文件夾指定具有相同佈局的不同xml文件,以符合您希望應用程序使用的設備屏幕。

這裏是關於文件夾結構如何可能看起來像一個例子:

res/layout/my_layout.xml    // layout for normal screen size ("default") 
res/layout-small/my_layout.xml  // layout for small screen size 
res/layout-large/my_layout.xml  // layout for large screen size 
res/layout-xlarge/my_layout.xml  // layout for extra large screen size 
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation 

res/layout/main_activity.xml   // For handsets (smaller than 600dp available width) 
res/layout-sw600dp/main_activity.xml // For 7」 tablets (600dp wide and bigger) 
res/layout-sw720dp/main_activity.xml // For 10」 tablets (720dp wide and bigger) 

(在應用程序清單)

<supports-screens 
     android:smallScreens="true" 
     android:normalScreens="true" 
     android:largeScreens="true" 
     android:xlargeScreens="true" 
     android:anyDensity="true"/> 

欲瞭解更多信息上支持多種屏幕,我強烈建議你閱讀的谷歌文檔關於它。 Here是文檔的鏈接。 http://developer.android.com/guide/practices/screens_support.html

+0

感謝它的權利.. – 2014-09-03 14:33:58

+0

不客氣!如果你將它標記爲正確的答案,我將不勝感激:) – Chris 2014-09-03 14:37:16

+0

正確答案@Chris – 2014-09-03 14:46:13

0

在android中,您必須根據屏幕尺寸設置不同的不同繪圖的圖像,並根據屏幕尺寸進行佈局。

res/layout/my_layout.xml(drawable also like layout) ---- default layout. 
res/layout-layout-hdpi/my_layout.xml ---- layout for hdpi screen size 
res/layout-layout-large-hdpi/my_layout.xml ---- layout for large hdpi screen size 
res/layout-layout-mdpi/my_layout.xml ---- layout for mdpi screen size(normal tables also) 
res/layout-layout-Xdpi/my_layout.xml ---- layout for Xhdpi screen Size(high resolution) 
+0

感謝您對我的支持 – 2014-09-03 14:34:16

+0

最受歡迎的..and thanx @jeba – 2014-09-04 05:23:49

0
You can proceed as following 

res/layout/my_layout.xml    // layout for normal screen size ("default") 
res/layout-small/my_layout.xml  // layout for small screen size 
res/layout-large/my_layout.xml  // layout for large screen size 
res/layout-xlarge/my_layout.xml  // layout for extra large screen size 
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation 

res/layout/main_activity.xml   # For handsets (smaller than 600dp available width) 
res/layout-sw600dp/main_activity.xml # For 7」 tablets (600dp wide and bigger) 
res/layout-sw720dp/main_activity.xml # For 10」 tablets (720dp wide and bigger) 

res/drawable-mdpi/my_icon.png  // bitmap for medium density 
res/drawable-hdpi/my_icon.png  // bitmap for high density 
res/drawable-xhdpi/my_icon.png  // bitmap for extra high density 


<supports-screens 
     android:smallScreens="true" 
     android:normalScreens="true" 
     android:largeScreens="true" 
     android:xlargeScreens="true" 
     android:anyDensity="true"/> 
+0

感謝您的支持。這個答案包括所有可能性.. – 2014-09-03 14:35:09