1

Ma mise en page s'affiche correctement sur l'émulateur avec la taille d'écran 5.0 ", mdpi (480 * 800) .Lorsque j'applique l'application avec la taille d'écran 5.0", 196ppi (480 * 854), la mise en page est coupée du bas.La mise en page est affichée différemment sur le périphérique et l'émulateur

J'ai essayé d'utiliser <supports-screens> mais cela ne faisait aucune différence.

layout.xml:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/create_trip_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="top" 
    android:orientation="vertical" > 

    <LinearLayout 
     style="@style/create_trip_activity_components_style" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="30dp" 
     android:gravity="center_vertical" 
     android:orientation="horizontal" > 

     <EditText 
      android:id="@+id/from_location" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginRight="5dp" 
      android:ems="10" 
      android:hint="@string/from_location_hint" 
      android:imeOptions="actionGo" 
      android:imeActionLabel="Ok" 
      android:inputType="text" > 

      <requestFocus /> 
     </EditText> 

     <Button 
      android:id="@+id/use_current_button" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="right" 
      android:onClick="useCurrentLocation" 
      android:text="@string/use_current" 
      android:textAppearance="?android:attr/textAppearanceSmall" /> 
    </LinearLayout> 

    <ImageButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="20dp" 
     android:layout_marginTop="20dp" 
     android:contentDescription="@string/swap_button_contentdescription" 
     android:onClick="swapLocations" 
     android:scaleType="fitStart" 
     android:src="@drawable/swap" /> 

    <EditText 
     android:id="@+id/to_location" 
     style="@style/create_trip_activity_components_style" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="20dp" 
     android:ems="10" 
     android:gravity="left" 
     android:hint="@string/to_location_hint" 
     android:imeOptions="actionGo" 
     android:imeActionLabel="Ok" 
     android:inputType="text" > 
    </EditText> 

    <LinearLayout 
     style="@style/create_trip_activity_components_style" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="25dp" 
     android:gravity="center_vertical" 
     android:orientation="horizontal" > 

     <EditText 
      android:id="@+id/departuretime_date" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:clickable="true" 
      android:ems="10" 
      android:focusable="false" 
      android:focusableInTouchMode="false" 
      android:gravity="center" 
      android:hint="@string/departure_date_hint" 
      android:inputType="datetime" > 
     </EditText> 

     <EditText 
      android:id="@+id/departuretime_time" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:clickable="true" 
      android:ems="10" 
      android:focusable="false" 
      android:focusableInTouchMode="false" 
      android:gravity="center" 
      android:hint="@string/departure_time_hint" 
      android:inputType="datetime" > 
     </EditText> 

    </LinearLayout> 

    <Button 
     android:id="@+id/pick_match_create_trip" 
     style="@style/big_centered_button_style" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="80dp" 
     android:onClick="pickMatchesButtonClicked" 
     android:text="@string/pick_your_matches" /> 

    <TextView 
     style="@style/create_trip_activity_components_style" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="75dp" 
     android:text="@string/current_location_textlabel" 
     android:textAppearance="?android:attr/textAppearanceSmall" /> 

    <TextView 
     android:id="@+id/current_location_text" 
     style="@style/create_trip_activity_components_style" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom" 
     android:layout_marginTop="5dp" 
     android:text="" 
     android:textAppearance="?android:attr/textAppearanceSmall" /> 

    <ListView 
     android:id="@+id/places_list" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginTop="20dp" 
     android:background="@color/white" > 
    </ListView> 

</LinearLayout> 
+0

référez-vous http://developer.android.com/guide/practices/screens_support.html –

+0

Le problème est que vous pouvez avoir un écran plus grand sur l'appareil que sur l'émulateur, mais vous avez moins de pixels physiques dans chaque direction et par conséquent un inférieur 'dpi'. Les pixels indépendants du périphérique (dp) se rapportent directement aux points par pouce et pas spécifiquement à la taille de l'écran. Vous aurez besoin de créer des dispositions différentes pour mdpi, hdpi, xhdpi etc – Squonk

+0

écran @Squonk périphérique est de 196 dpi et l'écran AVD est mdpi. Ils sont identiques. Alors la disposition ne devrait-elle pas ressembler aux deux? – Geek

Répondre

0

La seule façon est juste codage brillant dans la mise en page xml, et vérifier toutes les orientations d'écran disponibles et tailles dans la conception AGENCEMENT GRAPHIQUES tout à partir de zéro.

+0

Comme je l'ai mentionné en question, j'ai couru sur l'émulateur avec la même spécification que celle de l'appareil. Même cela montre une vue différente. – Geek

+0

Est-ce parfait dans la vue graphique? – Exceptional

+0

Oui. Dans la présentation graphique, il affiche tous les objets. – Geek

0

cela pourrait avoir à voir avec la densité d'image, si vous utilisez la même image de 720 dp, il pourrait se comporter de cette façon, pour un 480 * 800, la densité d'image devrait être de 320 dp pour un dp pour tablette tweener comme le Streak, pour d'autres références, vérifiez cela

320dp: un écran de téléphone typique (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc.). 480dp: une tablette tweener comme la Streak (480x800 mdpi). 600dp: une tablette de 7 "(600 x 1024 mdpi). 720dp: une tablette de 10 "(720x1280 mdpi, 800x1280 mdpi, etc.).

http://developer.android.com/guide/practices/screens_support.html

J'ai eu le même problème, j'ai utilisé un 720 dp, 720 * 1280 pour une tablette de 7 pouces et mon écran a été coupé, obtenir l'image 600 dp résolu mon problème et il fonctionne très bien avec la émulateur mais échoue sur le périphérique réel. Je ne suis pas sûr si cette solution fonctionnerait pour vous! mais bonne chance avec cela

0

S'il vous plaît Vérifiez si vous avez choisi le bon thème pour cette mise en page particulière. J'ai aussi eu le même problème.

Questions connexes