2017-10-24 1 views
-1

step.xml enthalten:Wie Layout am unteren Rand eines anderen Layout

<?xml version="1.0" encoding="utf-8"?> 
<com.stepstone.stepper.StepperLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/stepperLayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:ms_stepperType="dots" /> 

activity_main.xml:

<?xml version="1.0" encoding="utf-8"?> 
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:app="http://schemas.android.com/apk/res-auto" 
      android:id="@+id/ScrollView01" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"> 

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:paddingBottom="3dp" 
        android:paddingLeft="16dp" 
        android:paddingRight="16dp" 
        android:paddingTop="3dp"> 

        <android.support.design.widget.TextInputLayout 
        android:id="@+id/input_layout_name" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"> 

        <EditText 
         android:id="@+id/firstname" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:ems="11" 
         android:maxLines="1" 
         android:hint="First name" 
         android:textColor="#000000" 
         android:maxLength="15" 
         android:tag="@+id/first_name" 
         android:textCursorDrawable="@null" /> 

       </android.support.design.widget.TextInputLayout> 

    </RelativeLayout> 

    <include 
      android:id="@+id/bottom_Menu" 
      android:layout_alignParentBottom="true" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      layout="@layout/step"/> 

    </ScrollView> 

Dies ist das Design von step.xml

enter image description here

Dies ist das Design von activity_main. Dabei habe ich die step.xml enthalten

enter image description here

Ich brauche die Ausgabe wie folgt.

enter image description here

Wenn ich versuche step.xml in activity_main aufzunehmen, erhalte ich die Ausnahme „Scroll-Ansicht kann nur eine untergeordnete Ansicht hosten.“ Bitte hilf mir.

+0

Sie können nicht so tun. Lesen Sie die grundlegende Dokumentation über die XML-Codierung. –

+0

am wichtigsten Tag hat nur ein Kind-Tag –

+0

dann wie kann ich die step.xml zu activity_main hinzufügen? Gibt es eine Lösung? @RakeshPolo @J Ramesh – sagar

Antwort

2

Ihre StepperLayout Höhe zu Wrap Inhalt ändern.

Schritt.xml:

<?xml version="1.0" encoding="utf-8"?> 
<com.stepstone.stepper.StepperLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/stepperLayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:ms_stepperType="dots" /> 

Und ändern activity_main Layout wie folgt:

activity_main.xml:

<?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/profile_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:windowSoftInputMode="adjustResize|adjustPan"> 


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

     <ScrollView 
      android:id="@+id/layout_scroll" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:paddingLeft="16dp" 
       android:paddingRight="16dp" 
       android:paddingBottom="70dp" 
       android:paddingTop="3dp"> 

       <android.support.design.widget.TextInputLayout 
        android:id="@+id/input_layout_name" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"> 

        <EditText 
         android:id="@+id/firstname" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:ems="11" 
         android:maxLines="1" 
         android:hint="First name" 
         android:textColor="#000000" 
         android:maxLength="15" 
         android:tag="@+id/first_name" 
         android:textCursorDrawable="@null" /> 

       </android.support.design.widget.TextInputLayout> 

      </RelativeLayout> 


     </ScrollView> 


    </LinearLayout> 


    <RelativeLayout 
     android:id="@+id/btn_layout" 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:layout_alignParentBottom="true"> 

     <include 
      android:id="@+id/bottom_Menu" 
      android:layout_alignParentBottom="true" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      layout="@layout/step"/> 

    </RelativeLayout> 

</RelativeLayout> 
+0

Wenn Sie mehr Inhalt in der Bildlaufansicht hinzufügen möchten, dann machen Scroll Ansicht Kind auf lineares Layout (vertikal) statt relatives Layout. –

+0

Wenn diese Antwort Ihr Problem gelöst hat, dann markieren Sie es bitte als korrekt. –

0

Sie sollten ein einzelnes Kind in einem scrollview (wie der Fehler sagt) machen. Wickeln Sie alle Kinder innerhalb eines anderen (sagen wir) LinearLayout oder RelativeLayout mit wrap_content für die Breite und die Höhe sowie die vertikale Ausrichtung.

Von der Docs: Ein ScrollView ist ein FrameLayout, was bedeutet, dass Sie ein Kind darin platzieren sollten, das den gesamten Inhalt zum Scrollen enthält; Dieses Kind kann selbst ein Layout-Manager mit einer komplexen Hierarchie von Objekten sein. Ein Kind, das häufig verwendet wird, ist ein LinearLayout in vertikaler Ausrichtung, das ein vertikales Array von Elementen der obersten Ebene darstellt, durch die der Benutzer scrollen kann.

EDIT einfachstes Beispiel kann wie folgt sein:

<ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" > 
     <LinearLayout android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:orientation="vertical"> 
      // all the views currently in your ScrollView 
    </LinearLayout> 
</ScrollView> 
+0

Können Sie mir bitte mit dem Code – sagar

+0

erklären Ich habe meine Antwort aktualisiert –

+0

Sir, wo haben Sie das Stepperlayout in Ihrem Code enthalten? – sagar

0

StepperLayout Höhe ist Spiel Elternteil, das ist, warum es in der oberen Position ist, ändern Sie StepperLayout Höhe zu Wrap Inhalt

Schritt .xml

<?xml version="1.0" encoding="utf-8"?> 
<com.stepstone.stepper.StepperLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:id="@+id/stepperLayout" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
app:ms_stepperType="dots" /> 

Und Scrollview mit nur einem Kind so bewegen Ihr Layout innerhalb relativen Layout umfassen und android hinzufügen: fillViewport = "true" zu Scroll

 <?xml version="1.0" encoding="utf-8"?> 
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/ScrollView01" 
    android:layout_width="fill_parent" 
    android:fillViewport="true" 
    android:layout_height="fill_parent"> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="3dp" 
    android:paddingLeft="16dp" 
    android:paddingRight="16dp" 
    android:paddingTop="3dp"> 

<android.support.design.widget.TextInputLayout 
        android:id="@+id/input_layout_name" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"> 
        <EditText 
         android:id="@+id/firstname" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:ems="11" 
         android:maxLines="1" 
         android:hint="First name" 
         android:textColor="#000000" 
         android:maxLength="15" 
         android:tag="@+id/first_name" 
         android:textCursorDrawable="@null" /> 
       </android.support.design.widget.TextInputLayout> 
    <include 
      android:id="@+id/bottom_Menu" 
      android:layout_alignParentBottom="true" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      layout="@layout/step"/> 
    </RelativeLayout> 

    </ScrollView> 
+0

Ich habe StepperLayout hight geändert, um Inhalte zu umhüllen, obwohl sie oben, aber nicht unten enthalten sind. Überprüfen Sie Ihren Code einmal. @ Mohit Suthar – sagar

+0

Fügen Sie auch Ihr Schrittlayout innerhalb des relativen Planes hinzu –

+0

Ja, ich habe Ihren gleichen Code verwendet, aber er wird an der Oberseite hinzugefügt. – sagar

0

Mit diesem Code: Einmal-Tag die Scroll-Ansicht hat Beenden Sie den Schritt XML-Code wie folgt.

<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"> 

<LinearLayout 
     android:id="@+id/buttons" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:gravity="center" 
     android:layout_alignParentBottom="true"> 
    <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Custom Button1"/> 
    <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Custom Button2"/> 
</LinearLayout> 

<ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_above="@id/buttons"> 
    <!--Scrollable content here--> 
    <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical">     
     <TextView 
       android:layout_height="wrap_content" 
       android:layout_width="wrap_content" 
       android:text="test text" 
       android:textSize="40dp"/> 
    </LinearLayout> 
</ScrollView> 
<com.stepstone.stepper.StepperLayout 
android:id="@+id/stepperLayout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
app:ms_stepperType="dots" /> 
</RelativeLayout> 
Verwandte Themen