2014-09-03 2 views
0

У меня есть экран в формате XML. Когда я открываю широкоэкранный проект, он не адаптирует весь размер экрана. Как я могу преодолеть эту проблему.Мой проект не поддерживает просмотр нескольких устройств.

Когда я хочу добавить изображение об этой проблеме, я думаю, мне нужно 10 rep. point :)

Может ли кто-нибудь мне помочь?

<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 на картинке, это поможет выделить! Вам нужно только rep, чтобы вставить изображение в ваше сообщение. – Chris

+0

@Mustafa, вы можете попробовать ответить http://stackoverflow.com/questions/21329127/icon-resolution-constrains-for-android/21330125#21330125 – Jeba

ответ

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 очень спасибо –

1

В андроиде, чтобы поддерживать как можно больше устройств, вы можете предоставить несколько определений одного макета. Сначала вам нужно добавить эти папки в свои ресурсы, и для каждого из них вы можете указать разные 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"/> 

Для получения дополнительной информации на поддержку несколько экранов я настоятельно рекомендую читать документы Google об этом. Here - это ссылка на документы. http://developer.android.com/guide/practices/screens_support.html

+0

благодарит меня за это ... –

+0

Добро пожаловать ! Я был бы признателен, если бы вы отметили его как правильный ответ :) – Chris

+0

Правильный ответ @Chris –

0

В андроиде вы должны установить изображения в разных размерах в зависимости от размера экрана и сделать макет также по размеру экрана.

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

благодарит за это свое право –

+0

Большинство приветствуется .. и спасибоx @jeba –

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

благодаря своему праву для меня тоже. Этот ответ включал все возможности .. –

Смежные вопросы