title: Drag fragment up and down
body: <p>I have the main activity which is composed by two fragments one called Canvas and the other is the Palette. In the main activity, the palette only appears on 25% of the screen and I want to make it possible so that the user can drag it up and down to choose colors from it. I have no idea how to do it.</p>
  <h2>main.xml:</h2>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      android:orientation=&quot;vertical&quot;
      android:weightSum=&quot;2&quot;&gt;
  
      &lt;FrameLayout
          android:id=&quot;@+id/canvasFragment&quot;
          android:name=&quot;com.example.FragmentOne&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;0dp&quot;
          android:layout_weight=&quot;1.5&quot; /&gt;
  
      &lt;FrameLayout
          android:id=&quot;@+id/paletteFragment&quot;
          android:name=&quot;com.example.FragmentTwo&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;0dp&quot;
          android:layout_weight=&quot;0.5&quot; /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  <h2>mainActivity.java:</h2>
  <pre><code>package com.example.paint;
  
  import androidx.appcompat.app.AppCompatActivity;
  import androidx.fragment.app.Fragment;
  import androidx.fragment.app.FragmentTransaction;
  
  import android.annotation.SuppressLint;
  import android.content.Intent;
  import android.graphics.Color;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  
  public class MainActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          /**Canvas**/
          // Create new fragment and transaction
          Fragment canvasFragment = new CanvasFragment();
          //canvasFragment.getView().setBackgroundColor(this.cor);
          FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
          // Replace whatever is in the fragment_container view with this fragment,
          // and add the transaction to the back stack
          transaction.replace(R.id.canvasFragment, canvasFragment);
          transaction.addToBackStack(null);
          // Commit the transaction
          transaction.commit();
  
          /**Palette**/
          // Create new fragment and transaction
          Fragment paletteFragment = new PaletteFragment();
          FragmentTransaction transaction2 = getSupportFragmentManager().beginTransaction();
          // Replace whatever is in the fragment_container view with this fragment,
          // and add the transaction to the back stack
          transaction2.replace(R.id.paletteFragment, paletteFragment);
          transaction2.addToBackStack(null);
          // Commit the transaction
          transaction2.commit();
  
          setContentView(R.layout.activity_main);
      }
  
  
  }
  </code></pre>
  <h2>PaletteFragment.java:</h2>
  <pre><code>package com.example.paint;
  
  import android.os.Bundle;
  
  import androidx.fragment.app.Fragment;
  
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  
  import com.google.android.material.bottomsheet.BottomSheetBehavior;
  import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
  
  public class PaletteFragment extends BottomSheetDialogFragment {
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
  // Inflate the layout for this fragment
          return inflater.inflate(R.layout.fragment_palette, container, false);
      }
  
  }
  </code></pre>
  <p>Thanks for any help given.</p>