2016-11-20 1 views
0

Ich habe zwei Fragen erste habe ich ein Kind Layout und Ich will seinen Hintergrund auf grün gesetzt, aber wenn ich gesetzt habe ich dieses Layout bekam, das seine Farbe nicht gestreckt wird, unter pic enter image description hereSet Layout Hintergrund und heigh

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/image_Dead_Load" 
    android:layout_centerHorizontal="true" 
    android:layout_marginBottom="6dp" 
    android:layout_marginLeft="6dp" 
    android:layout_marginRight="6dp" 
    android:background="@drawable/layout_border" 
    android:paddingLeft="6dp" 
    android:paddingRight="6dp"> 

    <RelativeLayout 
     android:id="@+id/material_info" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:background="@color/green"> 

     <TextView 
      android:id="@+id/wall_material" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentEnd="true" 
      android:layout_alignParentRight="true" 
      android:layout_alignTop="@+id/material_thickness" 
      android:layout_gravity="center_horizontal" 
      android:layout_marginEnd="91dp" 
      android:layout_marginRight="110dp" 
      android:paddingLeft="5sp" 
      android:text="جنس مصالح" 
      android:textColor="@color/black" 
      android:textSize="15sp" /> 

     <TextView 
      android:id="@+id/material_thickness" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_horizontal" 
      android:layout_marginBottom="3dp" 
      android:paddingLeft="5sp" 
      android:text="ضخامت mm" 
      android:textColor="@color/black" 
      android:textSize="15sp" /> 
    </RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/brick_layout" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/material_info" 
     android:layout_marginTop="5dp"> 

     <EditText 
      android:id="@+id/editText_wall_width" 
      android:layout_width="100dp" 
      android:layout_height="30dp" 
      android:layout_alignBottom="@+id/wall_material_spinner" 
      android:layout_alignTop="@+id/wall_material_spinner" 
      android:layout_marginRight="3dp" 
      android:background="@drawable/textinputborder" 
      android:inputType="numberDecimal" 
      android:paddingLeft="5sp" 
      android:textColor="@color/black" /> 

     <Spinner 
      android:id="@+id/wall_material_spinner" 
      android:layout_width="wrap_content" 
      android:layout_height="25dp" 
      android:layout_toLeftOf="@+id/brick_material" 
      android:layout_toRightOf="@+id/editText_wall_width" 
      android:layout_toStartOf="@+id/brick_material" 
      android:background="@drawable/spinner_background" 
      android:spinnerMode="dropdown" /> 

     <TextView 
      android:id="@+id/brick_material" 
      android:layout_width="60dp" 
      android:layout_height="wrap_content" 
      android:layout_alignBaseline="@+id/wall_material_spinner" 
      android:layout_alignParentRight="true" 
      android:text="نوع آجر" 
      android:textColor="@color/gray_heavy" 
      android:textSize="15sp" /> 
    </RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/plastering_layout" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/brick_layout"> 

     <EditText 
      android:id="@+id/editText_plastering_material" 
      android:layout_width="100dp" 
      android:layout_height="30dp" 
      android:layout_alignBottom="@+id/plastering_material_spinner" 
      android:layout_alignTop="@+id/plastering_material_spinner" 
      android:layout_marginRight="3dp" 
      android:background="@drawable/textinputborder" 
      android:inputType="numberDecimal" 
      android:paddingLeft="5sp" 
      android:textColor="@color/black" /> 

     <Spinner 
      android:id="@+id/plastering_material_spinner" 
      android:layout_width="wrap_content" 
      android:layout_height="25dp" 
      android:layout_marginTop="7dp" 
      android:layout_toLeftOf="@+id/plastering_material" 
      android:layout_toRightOf="@+id/editText_plastering_material" 
      android:layout_toStartOf="@+id/plastering_material" 
      android:background="@drawable/spinner_background" 
      android:gravity="center_vertical" 
      android:spinnerMode="dropdown" /> 

     <TextView 
      android:id="@+id/plastering_material" 
      android:layout_width="60dp" 
      android:layout_height="wrap_content" 
      android:layout_alignBaseline="@+id/plastering_material_spinner" 
      android:layout_alignParentRight="true" 
      android:text="نوع اندود" 
      android:textColor="@color/gray_heavy" 
      android:textSize="15sp" /> 

    </RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/esther_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/plastering_layout"> 

     <TextView 
      android:id="@+id/esther_material" 
      android:layout_width="60dp" 
      android:layout_height="wrap_content" 
      android:layout_alignBaseline="@+id/esther_material_spinner" 
      android:layout_alignParentRight="true" 
      android:text="نوع آستر" 
      android:textColor="@color/gray_heavy" 
      android:textSize="15sp" /> 

     <Spinner 
      android:id="@+id/esther_material_spinner" 
      android:layout_width="wrap_content" 
      android:layout_height="25dp" 
      android:layout_marginTop="7dp" 
      android:layout_toLeftOf="@+id/esther_material" 
      android:layout_toRightOf="@+id/editText_esther_material" 
      android:layout_toStartOf="@+id/esther_material" 
      android:background="@drawable/spinner_background" 
      android:gravity="center_vertical" 
      android:spinnerMode="dropdown" /> 

     <EditText 
      android:id="@+id/editText_esther_material" 
      android:layout_width="100dp" 
      android:layout_height="30dp" 
      android:layout_alignBottom="@+id/esther_material_spinner" 
      android:layout_alignTop="@+id/esther_material_spinner" 
      android:layout_marginRight="3dp" 
      android:background="@drawable/textinputborder" 
      android:inputType="numberDecimal" 
      android:paddingLeft="5sp" 
      android:textColor="@color/black" /> 
    </RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/exterior_mortar_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/esther_layout"> 

     <TextView 
      android:id="@+id/exterior_mortar_material" 
      android:layout_width="60dp" 
      android:layout_height="wrap_content" 
      android:layout_alignBaseline="@+id/exterior_mortar_material_spinner" 
      android:layout_alignParentRight="true" 
      android:text="ملات بیرونی" 
      android:textColor="@color/gray_heavy" 
      android:textSize="12sp" /> 

     <Spinner 
      android:id="@+id/exterior_mortar_material_spinner" 
      android:layout_width="wrap_content" 
      android:layout_height="25dp" 
      android:layout_marginTop="7dp" 
      android:layout_toEndOf="@+id/editText_exterior_mortar_material" 
      android:layout_toLeftOf="@+id/exterior_mortar_material" 
      android:layout_toRightOf="@+id/editText_exterior_mortar_material" 
      android:background="@drawable/spinner_background" 
      android:gravity="center_vertical" 
      android:spinnerMode="dropdown" /> 

     <EditText 
      android:id="@+id/editText_exterior_mortar_material" 
      android:layout_width="100dp" 
      android:layout_height="30dp" 
                         android:layout_alignBottom="@+id/exterior_mortar_material_spinner"                        android:layout_alignTop="@+id/exterior_mortar_material_spinner" 
      android:layout_marginRight="3dp" 
      android:background="@drawable/textinputborder" 
      android:inputType="numberDecimal" 
      android:paddingLeft="5sp" 
      android:textColor="@color/black" /> 
    </RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/facing_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/exterior_mortar_layout"> 

     <TextView 
      android:id="@+id/facing_material" 
      android:layout_width="60dp" 
      android:layout_height="wrap_content" 
      android:layout_alignBaseline="@+id/facing_material_spinner" 
      android:layout_alignParentRight="true" 
      android:text="نوع نما" 
      android:textColor="@color/gray_heavy" 
      android:textSize="15sp" /> 

     <Spinner 
      android:id="@+id/facing_material_spinner" 
      android:layout_width="wrap_content" 
      android:layout_height="25dp" 
      android:layout_marginTop="7dp" 
      android:layout_toEndOf="@+id/editText_facing_material" 
      android:layout_toLeftOf="@+id/facing_material" 
      android:layout_toRightOf="@+id/editText_facing_material" 
      android:background="@drawable/spinner_background" 
      android:gravity="center_vertical" 
      android:spinnerMode="dropdown" /> 

     <EditText 
      android:id="@+id/editText_facing_material" 
      android:layout_width="100dp" 
      android:layout_height="30dp" 
      android:layout_alignBottom="@+id/facing_material_spinner" 
      android:layout_alignTop="@+id/facing_material_spinner" 
      android:layout_marginRight="3dp" 
      android:background="@drawable/textinputborder" 
      android:inputType="numberDecimal" 
      android:paddingLeft="5sp" 
      android:textColor="@color/black" /> 
    </RelativeLayout> 

    <Button 
     android:id="@+id/wall_loading_btn" 
     android:layout_width="150dp" 
     android:layout_height="36dp" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" 
     android:layout_marginTop="5dp" 
     android:background="@drawable/buttonshape" 
     android:gravity="center" 
     android:onClick="wallLoading" 
     android:text="محاسبه" 
     android:textColor="@color/white" 
     android:textSize="18sp" 
     android:textStyle="bold"></Button> 


</RelativeLayout> 

Zweitens auch, wie Sie sehen, ich verwende gleitende Registerkarte, dass seine Höhe nicht in android Studio Vorschau angezeigt wird: enter image description here

und ich konnte das Layout Höhe nicht festgelegt und meine blaue Taste ist auf dem letzter Spinner in einem echten Gerät (siehe erstes Bild) e) Wie kann ich sie lösen? Dank in Advanced

+1

fügen Sie bitte einen Code – Katharina

+0

der Code ist hinzugefügt ... – farshid83

+0

nur eine Frage: Sie möchten das ganze Kind Layout grün? Also alles innerhalb der Grenze? – Katharina

Antwort

1

Der Hintergrund füllt das gesamte "Material_info" Layout, aber dieses Layout füllt nicht die gesamte Breite. Wenn das Layout der gesamten Breite angepasst werden soll, entfernen Sie die Füllungen und Ränder des Layouts auf oberster Ebene und legen Sie sie für jedes untergeordnete Element einzeln fest.

Um den Effekt der abgerundeten Ecken zu erzielen, müssen Sie einen benutzerdefinierten Hintergrund festlegen. Sie können eine eigene Form wie folgt erstellen:

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http//schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 
    <solid android:color="@color/yourGreen" /> 
    <corners 
     android:bottomLeftRadius="0dp" 
     android:bottomRightRadius="0dp" 
     android:topLeftRadius="@dimen/yourRadius" 
     android:topRightRadius="@dimen/yourRadius" /> 
</shape> 

die zweite Frage: Sie werden auf die Registerkarte in Ihrer Vorschau nicht sehen, weil es wahrscheinlich ist in einem anderen Fragment/Activity der aktuellen Fragment in aufgeblasen Die Vorschau zeigt. nur die aktuelle View nicht alles, was in der App sichtbar ist

+0

hmmm ... Ich habe es aber, die grüne Farbe ist an der Grenze der Eltern Layout und die Ecke Engel ist 90 Grad http://picpaste.com/Capture-Zp4Ald1m.JPG und auch sehen Sie bitte meine zweite Frage – farshid83

+0

ich meine Antwort bearbeitet - Entschuldigung für die späte Antwort .. Ich habe vergessen auf Post zu klicken – Katharina

Verwandte Themen