2016-09-01 16 views
-4

Ich versuche, entworfen ein Android-App passen, aber ich habe ein Problem:Wie meine Android App auf allen Geräten

I App in Android-Studio erstellt und überprüft einmal Vorschau meiner android app, Look and Feel ist gut.

Aber wenn ich die app in meiner coolpad Note-3-Gerät laufen, so habe leider meine App Bezeichnung einmal in diesem Gerät geändert sehen Bild unten

enter image description here

In Android Studio Vorbetrachtungsbild unten einmal aussehen bei Bild

enter image description here

dies ist xml-Code hier:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
android:background="#5517ac" 
android:id="@+id/layoutroot" 
tools:context="com.example.shilpa.packitt.MainActivity" 
android:fitsSystemWindows="true"> 

<TextView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="Packitt" 
    android:textColor="#fefdff" 
    android:textSize="40sp" 
    android:gravity="center_horizontal"/> 

<!-- UserName Label --> 
<android.support.design.widget.TextInputLayout 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:layout_marginTop="50dp" 
android:layout_marginBottom="50dp" 
style="@style/AppTheme"> 
<EditText android:id="@+id/username" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:inputType="text" 
    android:hint="Username" 
    android:singleLine="true" 
    android:textSize="20sp" 
    android:textColorHint="#ccd2d7" 
    android:textColor="#fdfeff" 
    android:lines="1" 
    android:drawablePadding="5dp" 
    android:drawableLeft="@drawable/ic_person_black_24dp"> 
</EditText> 
</android.support.design.widget.TextInputLayout> 
<android.support.design.widget.TextInputLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="105dp" 
    android:layout_marginBottom="100dp" 
    style="@style/AppTheme"> 
    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/password" 
     android:textColorHint="#e2c7c7" 
     android:hint="Password" 
     android:textSize="20sp" 
     android:textColor="#fdfeff" 
     android:inputType="textPassword" 
     android:drawablePadding="5dp" 
     android:drawableLeft="@drawable/ic_lock_open_black_24dp"> 
    </EditText> 
</android.support.design.widget.TextInputLayout> 
<android.support.v7.widget.AppCompatButton 
    style="@style/ButtonNormalText" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="180dp" 
    android:text="Login"/> 
    <TextView 
     android:layout_width="175dp" 
     android:id="@+id/forgot_password" 
     android:layout_height="wrap_content" 
     android:text="Forgot Password" 
     android:textColor="#fdfdfd" 
     android:textSize="20sp" 
     android:layout_marginTop="255dp"/> 
<TextView 
    style="@style/AppTheme" 
    android:id="@+id/register" 
    android:layout_width="@dimen/_75sdp" 
    android:layout_height="@dimen/_25sdp" 
    android:text="Register" 
    android:fitsSystemWindows="true" 
    android:textColor="#fdfdfd" 
    android:textSize="@dimen/_20sdp" 
    android:layout_marginLeft="@dimen/activity_margin_Left" 
    android:layout_marginTop="255dp"/> 
<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="300dp" 
    android:text="____________________    _____________________" 
    android:textColor="#6f757b" 
    android:fitsSystemWindows="true"/> 
<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="(or)" 
    android:textSize="30sp" 
    android:fitsSystemWindows="true" 
    android:textColor="#97a0a9" 
    android:layout_marginLeft="145dp" 
    android:layout_marginTop="295dp"/> 
<Button 
    style="@style/SkipButtonText" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="350dp" 
    android:text="Skip and Continue as Guest"/> 

+0

Verwendung Gewichtssumme löst Ihre Verwendung. –

+0

post xml coding here –

+1

Es gibt unzählige Tutorials im Web, die sich mit Techniken befassen, um eine App auf verschiedenen Geräten zu verwenden. – Henry

Antwort

1

ich konfrontiert dies und ich kam zu diesem library wissen, man muss nur mit sdp dp und sp ersetzen wird das Layout entsprechend dem Gerät festgelegt oder können Sie separate Layout machen als different layout for devices gegeben und Sie können besuchen Sie designing multiscreen. Hoffe, dass Sie es wie diese Kompilierung Abhängigkeit tun können ‚com.intuit.sdp: SDP-android: 1.0.3‘

<TextView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="Packitt" 
    android:textColor="#fefdff" 
    android:textSize="@dimen/_40sdp" 
    android:gravity="center_horizontal"/> 

<!-- UserName Label --> 
<android.support.design.widget.TextInputLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="@dimen/_50sdp" 
    android:layout_marginBottom="@dimen/_50sdp" 
    style="@style/AppTheme"> 
    <EditText android:id="@+id/username" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:inputType="text" 
     android:hint="Username" 
     android:singleLine="true" 
     android:textSize="@dimen/_20sdp" 
     android:textColorHint="#ccd2d7" 
     android:textColor="#fdfeff" 
     android:lines="1" 
     android:drawablePadding="@dimen/_5sdp" 
     android:drawableLeft="@drawable/ic_person_black_24dp"> 
    </EditText> 
</android.support.design.widget.TextInputLayout> 
<android.support.design.widget.TextInputLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="@dimen/_105sdp" 
    android:layout_marginBottom="@dimen/_100sdp" 
    style="@style/AppTheme"> 
    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/password" 
     android:textColorHint="#e2c7c7" 
     android:hint="Password" 
     android:textSize="20sp" 
     android:textColor="#fdfeff" 
     android:inputType="textPassword" 
     android:drawablePadding="5dp" 
     android:drawableLeft="@drawable/ic_lock_open_black_24dp"> 
    </EditText> 
</android.support.design.widget.TextInputLayout> 
<android.support.v7.widget.AppCompatButton 
    style="@style/ButtonNormalText" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="180dp" 
    android:text="Login"/> 
<TextView 
    android:layout_width="175dp" 
    android:id="@+id/forgot_password" 
    android:layout_height="wrap_content" 
    android:text="Forgot Password" 
    android:textColor="#fdfdfd" 
    android:textSize="20sp" 
    android:layout_marginTop="255dp"/> 
<TextView 
    style="@style/AppTheme" 
    android:id="@+id/register" 
    android:layout_width="@dimen/_75sdp" 
    android:layout_height="@dimen/_25sdp" 
    android:text="Register" 
    android:fitsSystemWindows="true" 
    android:textColor="#fdfdfd" 
    android:textSize="@dimen/_20sdp" 
    android:layout_marginLeft="@dimen/activity_margin_Left" 
    android:layout_marginTop="@dimen/_255sdp"/> 
<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="@dimen/_300sdp" 
    android:text="____________________    _____________________" 
    android:textColor="#6f757b" 
    android:fitsSystemWindows="true"/> 
<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="(or)" 
    android:textSize="@dimen/_30sdp" 
    android:fitsSystemWindows="true" 
    android:textColor="#97a0a9" 
    android:layout_marginLeft="@dimen/_145sdp" 
    android:layout_marginStart="@dimen/_145sdp" 
    android:layout_marginTop="@dimen/_295sdp"/> 
<Button 
    style="@style/SkipButtonText" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="@dimen/_350sdp" 
    android:text="Skip and Continue as Guest"/> 
0

Sie Ihr Layout innerhalb Linearlayout erstellen sollte und Sie sollten alles in separaten Linearlayout platzieren. versuchen, statische Höhe zu vermeiden, Breite zu jeder Ansicht, Layout, weil, wenn Sie statische Höhe, Breite gab dann kann es nicht richtig eingestellt werden nach allen Bildschirmgrößen.

versuchen, diesen Code für Ihre Ansicht und es wird für die ganze Vorrichtung mit allen möglichen Bildschirmgrößen funktionieren: -

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_margin="10dp" 
    android:gravity="center" 
    android:orientation="horizontal"> 

    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="1dp" 
     android:layout_weight="1" 
     android:background="#000000" 
     android:gravity="center"> 


    </LinearLayout> 

    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_margin="5dp" 
     android:layout_weight=".3" 
     android:gravity="center"> 

      <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textSize="25dp" 
      android:text="(or)" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="1dp" 
     android:layout_weight="1" 
     android:gravity="center" 
     android:background="#000000"> 

    </LinearLayout> 

</LinearLayout> 
+0

ich versuchte dies, aber es funktioniert nicht –

+0

seine Arbeit für mich, bitte teilen Sie Ihr ganzes Layout. – Pawanpreet

+0

ich post xml code einmal überprüfen –

Verwandte Themen