2016-10-09 1 views
0

il y a un code de ma mise en page:Android: Voir sur l'aperçu du design est pas comme le vrai

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <ImageView 
     android:layout_width="119dp" 
     android:layout_height="84dp" 
     android:src="@drawable/image_template" 
     android:id="@+id/roleIco" 
     android:scaleType="fitCenter" 
     android:layout_marginBottom="16dp" 
     android:layout_marginTop="16dp" /> 

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 
     <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="the name of the player" 
     android:id="@+id/playerName" 
     android:textAppearance="@style/TextAppearance.AppCompat.Body2" 
     android:layout_marginTop="16dp" 
     android:layout_marginLeft="8dp" 
     android:layout_marginEnd="16dp" 
     android:layout_marginRight="16dp" /> 

     <TextView 
      android:text="Role name" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/roleName" 
      android:textAppearance="@style/TextAppearance.AppCompat.Body1" 
      android:layout_marginTop="16dp" /> 

     <TextView 
      android:text="Fraction" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/fractionName" 
      android:layout_marginTop="16dp" 
      android:textAppearance="@style/TextAppearance.AppCompat.Subhead" /> 

    </LinearLayout> 

    <ImageView 
     android:layout_width="74dp" 
     android:layout_height="match_parent" 
     android:src="@drawable/icon_heart" 
     android:id="@+id/playerStatusIcon" 
     android:scaleType="fitCenter" /> 


</LinearLayout> 

Et le problème est que, en avant-première conception dans Android studio, il ressemble à ça: See this image, please

Mais quand je lance cette application sur le téléphone, il ressemble à ceci:

See this image, please

Quelqu'un pourrait aider moi quelle est la raison de cette différence et comment l'éliminer et changer la vue réelle à cela comme sur l'aperçu?

Merci pour la réponse;)

+0

faites-vous référence à la couleur du texte en avant-première? – Sanjeet

+0

Vous n'avez pas défini d'orientation pour la disposition linéaire parent. Essayez de définir son orientation sur 'horizontal'. –

+0

@Vaibhav Agarwal orientation par défaut est toujours horizontale même si vous ne le définissez pas –

Répondre

0

Preview est différent parce que vous êtes voient aperçu selon l'API Niveau 24 alors que l'image que vous pour le dispositif réel attaché est au-dessous API de niveau 21.

Par conséquent, il n'y a pas de Material Design disponible dans votre appareil réel et donc il y a la différence. Essayez-le dans un vrai appareil fonctionnant sous Android Lollipop ou supérieur vous obtiendrez les mêmes résultats.