2016-08-05 2 views
0

only white portion is taken and that too after taking match_parentmatch_parentは、私は、このレイアウトを追加しようとしてきた、望ましい結果

を満たしていません。すべてうまく動作します。私は2番目のEditTextレイアウトの残りの高さをすべて取るようにします。私はEditTextmatch_parentとしましたが、すべてのスペースを取ることはできません。 誰かが私に持っている問題を教えてもらえますか?

<?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は使用しないでください。 match_parentを使用してください。それらは同じですが、塗りつぶしは古いです2)scrollviewの直接の子はwrap_contentの高さが –

+0

であると信じていますEditTextに 'android:singleLine =" false "'を追加してみてください。 – Vucko

+0

@TimCastelijnsは両方を試しました。うまくいかなかった。 –

答えて

0

使用アンドロイド:fillViewport =「true」をあなたのスクロールビューで、それはあなたが編集テキストに重みを設定しますが、親layout.Set重量に重量の合計を設定していない、あなたのXMLでscreen.Andをいっぱいになります線形レイアウト上にある。

<?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

それは働いたが、私はまだ問題がある。私のFABはレイアウトscroolでスクロールされています。レイアウトが上下にスクロールしても静的にする必要があります。 –

+0

スクロールビューを相対レイアウト内に配置し、FABを相対レイアウトの子を直接指定し、必要な場所にFABを設定します。@ AbhishekKumar –

+0

ずっと親友です。 :) –

0

はこれを試してください: -

<?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> 

あなたは属性android:fillViewport="true"を使用する必要があります。この値がtrueに設定されている場合、必要に応じて、スクロールビューの高さに子が展開されます。子供がScroll Viewより背が高い場合、その場合は効果がありません。

0

これを試してください:レイアウトが上下にスクロールしてもFABを静的にすることができます。

<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

どこでscrollviewwを閉じるのですか? –

+0

@AbhishekKumar plzチェック、私は編集しました。 –

関連する問題