2017-03-24 11 views
0

相対レイアウトを動的に増減させ、リサイクルビューのポップアップを画面の下部から縮小し、画面を通常のサイズに戻す(リサイクラで相対ビューを表示するアイコンを表示する)相対的なレイアウトを動的に増減する

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    android:layout_weight="1"> 

////////tool bar 
    <include layout="@layout/toolbar" /> 


    <RelativeLayout 
     android:id="@+id/rel1" 
     android:layout_width="wrap_content" 
     android:layout_height="400dp" 
     android:layout_below="@+id/toolbar" 
     android:layout_weight="1"> 

     <com.cmlibrary.CircleMenu 
      android:id="@+id/circle_menu" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="180dp" 
      android:layout_marginTop="180dp" 

      /> 
    </RelativeLayout> 
    <android.support.v7.widget.RecyclerView 
     android:id="@+id/recycler_view" 
     android:layout_width="match_parent" 
     android:layout_height="300dp" 
     android:layout_below="@+id/rel1" 
     android:padding="5dp" /> 
    </RelativeLayout> 
+0

ようこそ! [良い質問をするにはどうすればいいですか?](https://stackoverflow.com/help/how-to-ask)と[最小限の完全かつ検証可能なサンプルを作成する方法](https:// stackoverflow.com/help/mcve)。 – Olaia

答えて

0

より良い方法は、必要に応じてビューの表示を非表示にすることです。しかし、サイズを増減したい場合は、以下のコードを参考にしてください。

private void layoutParams() { 
    RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) relativeLayout.getLayoutParams(); 
    ViewGroup.LayoutParams params = recyclerView.getLayoutParams(); 
    /* When recyclerView shows*/ 
    layoutParams.height = layoutParams.height - params.height; 
    relativeLayout.setLayoutParams(layoutParams); 

    /* When recyclerView hidden*/ 
    layoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT; 
    relativeLayout.setLayoutParams(layoutParams); 
} 

希望すると、これが役に立ちます。

+0

リサイクラビューを相対レイアウトの上に表示する方法とリサイクラビューを使用した後にリサイクルビューのアイコンを使用してアイコンを設定した後、そのビューを非表示にする方法 – Abhinav

関連する問題