2017-10-24 2 views
0

エミュレータはUIのすべての要素を表示していますが、プレビューに比べてすべて縮小されています。わかりやすくするためにスクリーンショット:以下Android Studioエミュレータ縮小バージョンのAppを表示

私はエミュレータに表示されるUIを希望する方法である:

以下

はUIがエミュレータに表示されている方法です。ご覧のように、画像、EditTextボックス、およびボタンは、プレビューと同じパーセンテージのスペースを占めるわけではありません。ここで

活動のための私のXMLコードです:android:layout_width & android:layout_heightなどのパラメータは、あなたがしているデバイスの密度に基づいて調整されますので、

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    android:background="@color/clarksonGreen" > 

    <ImageView 
     android:id="@+id/imageView2" 
     android:layout_width="577dp" 
     android:layout_height="595dp" 
     android:alpha="0.1" 
     android:layout_gravity="center" 
     app:srcCompat="@drawable/login_background" /> 

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

     <ImageView 
      android:id="@+id/imageView" 
      android:layout_gravity="center" 
      android:layout_width="266dp" 
      android:layout_height="255dp" 
      android:layout_marginBottom="30dp" 
      android:layout_marginTop="20dp" 
      app:srcCompat="@drawable/knight" /> 

     <EditText 
      android:id="@+id/enterEmail" 
      android:layout_width="274dp" 
      android:layout_height="48dp" 
      android:textColor="@color/closeBlack" 
      android:ems="10" 
      android:background="@drawable/rounded_corners" 
      android:hint="Enter Email" 
      android:layout_gravity="center" 
      android:textColorHint="#808080" 
      android:inputType="textEmailAddress" 
      android:layout_marginBottom="8dp" 
      android:layout_marginTop="8dp" 
      android:layout_marginRight="8dp" 
      android:layout_marginLeft="8dp" /> 

     <EditText 
      android:id="@+id/enterPassword" 
      android:layout_width="273dp" 
      android:layout_height="46dp" 
      android:layout_marginBottom="8dp" 
      android:layout_marginLeft="8dp" 
      android:layout_marginRight="8dp" 
      android:layout_marginTop="8dp" 
      android:background="@drawable/rounded_corners" 
      android:ems="10" 
      android:fontFamily="sans-serif" 
      android:hint="Enter Password" 
      android:layout_gravity="center" 
      android:inputType="textPassword" 
      android:textColor="@color/closeBlack" 
      android:textColorHint="#808080" /> 

     <Button 
      android:id="@+id/logIn" 
      android:layout_gravity="center" 
      android:layout_width="274dp" 
      android:layout_height="61dp" 
      android:layout_marginLeft="8dp" 
      android:layout_marginRight="8dp" 
      android:layout_marginTop="8dp" 
      android:background="@color/clarksonYellow" 
      android:text="Log in" 
      android:textColor="@color/clarksonGreen" 
      android:textSize="20dp" /> 


    </LinearLayout> 

</FrameLayout> 

答えて

0

dpは、濃度画素の略を使用して。画面の密度によって多少異なる場合があります。代わりImageView & EditTextような要素に、特定の幅&高さを指定する

margin & padding適切に提供次いでmatch_parent又はwrap_content &のいずれかを適用します。すべての画面で必要に応じて拡大縮小します。

参考:Supporting Multiple Screens - Android Developers Documentation

関連する問題