2017-11-17 5 views
0

最後のビューが一番下に並んでいるソリューションがたくさんありますが、柔軟にする必要があります。以下のリストとポジティブ/ネガティブボタンを持つダイアログを想像してみてください。少数の要素がある場合、私はそれは次のようになりたいのですが:enter image description hereRecyclerView(オーバーラップなし)

そして多くの項目がある場合、このダイアログは、下に自分自身を展開するので、のようにする必要があります

enter image description here

LinearLayout内部のレイアウト構造は、次のとおりです。

title layout 
RecyclerView 
buttons layout 

私はそれだけで私のボタンをオーバーラップし大成功せずLinearLayout内部RecyclerViewをラップしようとした

+1

ボタンレイアウトを下にした相対レイアウトを使用します。そしてリサイクル業者のビューはボタンの上で、親の高さに合わせてタイトルの下に表示されます。 – ADM

+0

@ADMもし私がRecyclerViewにカップルのアイテムを持っていれば、それはあなたの解決策を使ってたくさんの空きスペースになるでしょう。 –

+0

そうです。その場合、警告ダイアログを使用する必要があります。 – ADM

答えて

0
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@mipmap/splash" 
android:orientation="vertical"> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/card_listing" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/btn_add_card" 
     android:layout_below="@+id/card_line" 
     android:layout_margin="10dp" 
     android:dividerHeight="2dp" 
     android:visibility="visible" /> 

    <TextView 
     android:id="@+id/error_message" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_alignParentTop="true" 
     android:layout_toEndOf="@+id/card_listing" 
     android:layout_toRightOf="@+id/card_listing" 
     android:gravity="center" 
     android:text="@string/internet_toast" 
     android:textColor="@color/white" 
     android:textSize="20sp" 
     android:visibility="gone" /> 

    <Button 
     android:id="@+id/btn_add" 
     style="@style/ButtonStyle" 
     android:layout_above="@+id/pay_now" 
     android:layout_marginBottom="10dp" 
     android:layout_marginTop="10dp" 
     android:text="Button" /> 
</RelativeLayout> 
0

NestedScrollViewを使用するのが最善の方法です。

<NestedScrollView> 
    <LinearLayout> 
    <YourTitleLayout> 
    <RecyclerView> 
    <YourLayoutBelowRecyclerView> 
</LinearLayout> 
</NestedScrollView> 

このネストされたscrollViewは、名前が示すようにアイテムが次々にスクロールされることを保証します。お役に立てれば。

+0

3つのビューはすべてスクロール可能ですが、recyclerviewの場合のみスクロールする必要があります –

+0

次に、xmlのrecyclerViewの高さを定義します。その高さを超えず、その特定の領域でスクロール可能になります。 –

+0

高さは動的にする必要があります。ハードコードされた高さを設定すると、リサイクルビューの理由は何ですか? –

関連する問題