2014-09-03 40 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