2017-04-02 7 views
1

Hey Leute, also habe ich andere Fragen in Bezug auf diese und ich sah sogar online und ich sehe nichts falsch mit meinem Code, aber jedes Mal, wenn ich versuche, einen AVD zu machen, um zu sehen, wie die App sieht aus, dass die Knöpfe nicht Seite an Seite zeigen, aber in Android Studio Render-Bildschirm tut es.Android- machen 2 Tasten nebeneinander

Wenn jemand helfen könnte, wäre ich wirklich dankbar!

Dies ist, wenn ich die AVD in Android Studio laden enter image description here

Dies ist, wie zeigt in der Render in Android Studio ist enter image description here

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_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" 
    tools:context="com.example.jarvis.imquest.MainActivity"> 

    <ImageView 
     android:id="@+id/image_message" 
     android:src="@drawable/ic_message" 
     android:layout_marginTop="20dp" 
     android:layout_centerHorizontal="true" 
     android:layout_width="100dp" 
     android:layout_height="100dp" /> 

    <LinearLayout 
     android:orientation="vertical" 
     android:layout_below="@+id/image_message" 
     android:id="@+id/group_login" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <android.support.design.widget.TextInputLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <EditText 
       android:id="@+id/main_editLogin" 
       android:hint="Enter Username" 
       android:padding="5dp" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"/> 
     </android.support.design.widget.TextInputLayout> 

     <android.support.design.widget.TextInputLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <EditText 
       android:id="@+id/main_editPassword" 
       android:hint="Enter Password" 
       android:padding="5dp" 
       android:inputType="textPassword" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"/> 
     </android.support.design.widget.TextInputLayout> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_below="@+id/group_login" 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:weightSum="2"> 

     <Button 
      android:layout_weight="1" 
      android:id="@+id/main_btnLogin" 
      android:background="@color/colorPrimaryDark" 
      android:textColor="@color/colorAccent" 
      android:text="Login" 
      android:layout_marginRight="5dp" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      style="@style/Widget.AppCompat.Button.Borderless" 
      /> 

     <Button 
      android:layout_weight="1" 
      android:id="@+id/main_btnSignup" 
      android:background="@color/colorPrimaryDark" 
      android:textColor="@color/colorAccent" 
      android:text="SignUp" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      style="@style/Widget.AppCompat.Button.Borderless" 
      /> 
    </LinearLayout> 


</RelativeLayout> 
+0

Können Sie bitte Ihren vollständigen XML-Code posten? – FAT

+0

Ich postete den vollständigen XML-Code dafür – Mohamed

+0

layout_height ist Match-Parent für Ihre lineare layour von Schaltflächen? mach es wrap Inhalt –

Antwort

2

Attribut hinzufügen android:weightSum="2" zu Ihrem LinearLayout und entfernen attributeandroid:layout_toRightOf="@+id/main_btnLogin" aus Anmeldeschaltfläche

Try this:

<LinearLayout 
     android:layout_below="@+id/group_login" 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:weightSum="2"> 

     <Button 
      android:layout_weight="1" 
      android:id="@+id/main_btnLogin" 
      android:background="@color/colorPrimaryDark" 
      android:textColor="@color/colorAccent" 
      android:text="Login" 
      android:layout_marginRight="5dp" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      style="@style/Widget.AppCompat.Button.Borderless" 
      /> 

     <Button 
      android:layout_weight="1" 
      android:id="@+id/main_btnSignup" 
      android:background="@color/colorPrimaryDark" 
      android:textColor="@color/colorAccent" 
      android:text="SignUp" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      style="@style/Widget.AppCompat.Button.Borderless" 
      /> 
    </LinearLayout> 

OUTPUT auf meinem Galaxy Note3 Gerät:

enter image description here

enter image description here

+0

komisch, ich weiß nicht, warum es nicht funktioniert für mich – Mohamed

+0

Ich habe ein Bild von meinem realen Gerät erfasst. Führen Sie Ihre App auf einem echten Gerät aus. Hoffe, es wird perfekt funktionieren :) – FAT

+0

@Mohamed jedes Update. funktioniert es? – FAT

0

versuchen, diese

<LinearLayout 
    android:layout_below="@+id/group_login" 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    > 

    <Button 
     android:id="@+id/main_btnLogin" 
     android:background="@color/colorPrimaryDark" 
     android:textColor="@color/colorAccent" 
     android:text="Login" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     style="@style/Widget.AppCompat.Button.Borderless" 
     /> 

    <Button 
     android:id="@+id/main_btnSignup" 
     android:background="@color/colorPrimaryDark" 
     android:textColor="@color/colorAccent" 
     android:text="SignUp" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     style="@style/Widget.AppCompat.Button.Borderless" 
     /> 
</LinearLayout>