2016-08-05 19 views
0

only white portion is taken and that too after taking match_parentmatch_parent füllt nicht das gewünschte Ergebnis

Ich habe dieses Layout hinzuzufügen versucht. Alles funktioniert gut. Ich möchte die zweite EditText die gesamte Höhe des Layouts nehmen. Ich habe dieses EditText als match_parent gemacht, aber es kann nicht den ganzen Raum nehmen. kann mir jemand das Problem sagen, das ich habe?

<?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" 
      xmlns:app="http://schemas.android.com/apk/res-auto"> 


<LinearLayout xmlns:tools="http://schemas.android.com/tools" 
       android:orientation="vertical" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:background="#fff" 
       android:id="@+id/createxml_layout_id"> 

    <EditText 
       android:id="@+id/createxml_title_id" 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_weight="1" 
       android:scrollHorizontally="true" 
       android:hint="Title" 
       android:textAlignment="center" 
       android:textColor="#000" 
       android:textAllCaps="true" 
       android:textSize="20sp" 
       android:maxLength="20" 
       android:autoText="false" 
       android:inputType="textPersonName" 
       android:gravity="fill_horizontal" 
       android:textAppearance="?android:attr/textAppearanceMedium" /> 

    <EditText 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:hint="CONTENT HERE" 
      android:id="@+id/createxml_content_id" 
      android:textSize="14sp" 
      android:layout_gravity="top"/> 

    <android.support.design.widget.FloatingActionButton 

      android:id="@+id/fab" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="bottom|end" 
      app:fabSize="mini" 
      android:layout_margin="10dp" 
      android:src="@android:drawable/ic_dialog_email" > 

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

    <!--</LinearLayout>--> 

    </LinearLayout> 

    </ScrollView> 
+0

1) fill_parent nicht verwenden. Verwenden Sie match_parent. Sie sind die gleichen, aber Füllung ist alt 2) Ich glaube, eine direkte scrollview Kind sollte wrap_content als Höhe haben –

+0

Versuchen Sie, Hinzufügen von 'android: singleLine =" false "' zum EditText. – Vucko

+0

@TimCastelijns versuchte beides. hat nicht funktioniert. –

Antwort

0

Verwendung android: fillViewport = „true“ in der Scroll-Ansicht wird es den screen.And in Ihrem xml füllen Sie Gewicht auf edit-Text festgelegt ist, aber nicht Gewichtssumme auf Mutter layout.Set Gewicht eingestellt -sum auf linearem Layout.

<?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:fillViewport="true" 
    xmlns:app="http://schemas.android.com/apk/res-auto"> 


    <LinearLayout xmlns:tools="http://schemas.android.com/tools" 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="#fff" 
     android:weightSum="2" 
     android:id="@+id/createxml_layout_id"> 

     <EditText 
      android:id="@+id/createxml_title_id" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:scrollHorizontally="true" 
      android:hint="Title" 
      android:textAlignment="center" 
      android:textColor="#000" 
      android:textAllCaps="true" 
      android:textSize="20sp" 
      android:maxLength="20" 
      android:autoText="false" 
      android:inputType="textPersonName" 
      android:gravity="fill_horizontal" 
      android:textAppearance="?android:attr/textAppearanceMedium" /> 

     <EditText 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:hint="CONTENT HERE" 
      android:id="@+id/createxml_content_id" 
      android:textSize="14sp" 
      android:layout_gravity="top"/> 

     <android.support.design.widget.FloatingActionButton 

      android:id="@+id/fab" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="bottom|end" 
      app:fabSize="mini" 
      android:layout_margin="10dp" 
      android:src="@android:drawable/ic_dialog_email" > 

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

     <!--</LinearLayout>--> 

     </LinearLayout> 

    </ScrollView> 
+0

es funktionierte, aber ich habe immer noch ein Problem. Mein FAB wird mit dem Layout-Scroll runtergescrollt. Ich muss es statisch machen, auch wenn das Layout nach oben oder unten scrollt. –

+0

Setzen Sie die Bildlaufansicht in ein relatives Layout und machen Sie Ihren FAB so, dass er direkt untergeordnete Elemente des relativen Layouts anordnet und setzen Sie Ihren FAB dort, wo Sie ihn haben möchten. @ AbhishekKumar –

+0

Vielen Dank, Kumpel. :) –

0

Try this: -

<?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:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:fillViewport="true"> 


<LinearLayout xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/createxml_layout_id" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#fff" 
    android:orientation="vertical"> 

    <EditText 
     android:id="@+id/createxml_title_id" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:autoText="false" 
     android:gravity="fill_horizontal" 
     android:hint="Title" 
     android:inputType="textPersonName" 
     android:maxLength="20" 
     android:scrollHorizontally="true" 
     android:textAlignment="center" 
     android:textAllCaps="true" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:textColor="#000" 
     android:textSize="20sp" /> 

    <EditText 
     android:id="@+id/createxml_content_id" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="10" 
     android:hint="CONTENT HERE" 
     android:textSize="14sp" /> 

    <android.support.design.widget.FloatingActionButton 

     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|end" 
     android:layout_margin="10dp" 
     android:src="@android:drawable/ic_dialog_email" 
     app:fabSize="mini"> 

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

    <!--</LinearLayout>--> 

</LinearLayout> 

Sie benötigen android:fillViewport="true" das Attribut zu verwenden. Wenn der Wert auf "true" gesetzt ist, bewirkt dies, dass child auf die Höhe der Bildlaufansicht maximiert wird, wenn dies erforderlich ist. Wenn das Kind größer als Scroll View ist, hat es in diesem Fall keine Wirkung.

0

Versuchen Sie Folgendes: Es hilft, FAB statisch zu machen, auch wenn das Layout nach oben oder unten scrollt.

<LinearLayout 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

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

    <LinearLayout xmlns:tools="http://schemas.android.com/tools" 
     android:id="@+id/createxml_layout_id" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="#fff" 
     android:orientation="vertical"> 

    <EditText 
     android:id="@+id/createxml_title_id" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:autoText="false" 
     android:gravity="fill_horizontal" 
     android:hint="Title" 
     android:inputType="textPersonName" 
     android:maxLength="20" 
     android:scrollHorizontally="true" 
     android:textAlignment="center" 
     android:textAllCaps="true" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:textColor="#000" 
     android:textSize="20sp" /> 

    <EditText 
     android:id="@+id/createxml_content_id" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="10" 
     android:hint="CONTENT HERE" 
     android:textSize="14sp" /> 

</LinearLayout> 
</ScrollView> 

<RelativeLayout 
     android:id="@+id/fab_frame_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/white_overlay"> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|end" 
     android:layout_margin="10dp" 
     android:src="@android:drawable/ic_dialog_email" 
     app:fabSize="mini"/> 

</RelativeLayout> 
</LinearLayout> 
+0

wo die scrollvieww zu schließen? –

+0

@AbhishekKumar PLZ überprüfen, habe ich bearbeitet. –