2016-05-17 50 views
-1

你好,這是我的登錄表單與背景似乎是這個形象。如何設計適用於所有智能手機和平板電腦分辨率的應用程序?

enter image description here

我想顯示自己的內容(所有的EditText,按鈕),只能在藍色區域。 genymotion一切正常,但當我在智能手機上測試我的應用時,結果讓我感到驚訝。按鈕和textview在紅色區域。我怎樣才能更正我的代碼來獲取接口的所有智能手機和平板電腦的分辨率提前

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:fitsSystemWindows="true" 
    android:background="@drawable/login_full2"> 

    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="200dp" 
     android:layout_marginLeft="60dp" 
     android:layout_marginRight="60dp"> 
     <!-- Login Label --> 

      <EditText android:id="@+id/et_login" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:inputType="text" 
       android:drawableStart="@drawable/ic_account_circle_black_24dp" 
       android:drawableLeft="@drawable/ic_account_circle_black_24dp" 
       android:hint="@string/Login" /> 

     <!-- Password Label --> 
      <EditText android:id="@+id/et_password" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:inputType="textPassword" 
       android:drawableStart="@drawable/ic_lock_black_24dp" 
       android:drawableLeft="@drawable/ic_lock_black_24dp" 
       android:hint="@string/Password"/> 


     <Button 
      android:id="@+id/btn_valider" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="20dp" 
      android:layout_marginBottom="20dp" 
      android:background="@drawable/colorbutton" 
      android:padding="12dp" 
      android:text="@string/Connexion"/> 

     <TextView android:id="@+id/link_signup" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="12dp" 
      android:text="Vous n'avez pas encore de compte ? Créez-en un !" 
      android:textSize="12sp"/> 
     <TextView android:id="@+id/pass_oub" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="J'ai oublié mon mot de passe" 
      android:textSize="12sp"/> 

    </LinearLayout> 
</ScrollView> 

感謝

+2

你閱讀文件? https://developer.android.com/training/multiscreen/index.html – tyczj

+0

是的我對此有一個想法,但我不知道該怎麼做才能在藍色區域中設置我的編輯文本和按鈕 – clara

+0

那麼,你有什麼試過嗎? –

回答

0
<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:fitsSystemWindows="true" 
android:background="@drawable/login_full2"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:padding="10dp" 
    android:orientation="vertical"> 
    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="40dp" 
     android:layout_marginStart="40dp" 
     android:layout_marginRight="40dp" 
     android:layout_marginEnd="40dp"> 
     <!-- Login Label --> 

     <EditText android:id="@+id/et_login" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:inputType="text" 
      android:drawableStart="@drawable/ic_account_circle_black_24dp" 
      android:drawableLeft="@drawable/ic_account_circle_black_24dp" 
      android:hint="@string/Login" /> 

     <!-- Password Label --> 
     <EditText android:id="@+id/et_password" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:inputType="textPassword" 
      android:drawableStart="@drawable/ic_lock_black_24dp" 
      android:drawableLeft="@drawable/ic_lock_black_24dp" 
      android:hint="@string/Password"/> 


     <Button 
      android:id="@+id/btn_valider" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="20dp" 
      android:layout_marginBottom="20dp" 
      android:padding="12dp" 
      android:text="@string/Connexion"/> 

     <TextView android:id="@+id/link_signup" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:padding="5dp" 
      android:layout_marginBottom="12dp" 
      android:text="Vous n'avez pas encore de compte ? Créez-en un !" 
      android:textSize="12sp"/> 
     <TextView android:id="@+id/pass_oub" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:padding="5dp" 
      android:text="J'ai oublié mon mot de passe" 
      android:textSize="12sp"/> 

    </LinearLayout> 
</LinearLayout> 
</ScrollView> 
+0

上述xml將適用於手機和Tab視圖,但內容的大小將不會相同,這對移動設備並越來越小屏幕變得更大。您必須分別爲layout-sw680dp上的Tab創建佈局,並進行對齊。 – Franklyn

+0

與此代碼,當我點擊edittext,鍵盤出現,但整個內容(editext,tetview和按鈕)在紅色區域向上移動 – clara

+0

這意味着當佈局在滾動視圖上時發生。 Android SoftInput鍵盤傾向於將當前焦點的其他視圖移動到用戶可見的位置。嘗試將此屬性(android:windowSoftInputMode =「adjustPan」)添加到正在應用的清單活動中。這個屬性有幾個選項適合你。 – Franklyn

相關問題