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

    <com.sothree.slidinguppanel.SlidingUpPanelLayout 
     xmlns:sothree="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/sliding_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:gravity="bottom" 
     sothree:umanoPanelHeight="68dp" 
     sothree:umanoShadowHeight="4dp" 
     sothree:umanoParallaxOffset="100dp" 
     sothree:umanoDragView="@+id/dragView" 
     sothree:umanoOverlay="true" 
     sothree:umanoScrollableView="@+id/main"> 

     <!-- MAIN CONTENT --> 
     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 
      <android.support.v7.widget.Toolbar 
       xmlns:sothree="http://schemas.android.com/apk/res-auto" 
       xmlns:android="http://schemas.android.com/apk/res/android" 
       android:id="@+id/main_toolbar" 
       android:layout_height="?attr/actionBarSize" 
       android:background="?attr/colorPrimary" 
       sothree:theme="@style/ActionBar" 
       android:layout_width="match_parent"/> 
     <android.support.v7.widget.RecyclerView 
      android:id="@+id/recyclerview" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:scrollbars="vertical" 
      android:layout_marginTop="?attr/actionBarSize" 


      /> 
     </RelativeLayout> 
     <!-- SLIDING LAYOUT --> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="#ffffff" 
      android:orientation="vertical" 
      android:clickable="true" 
      android:focusable="false" 
      android:id="@+id/dragView"> 
     <LinearLayout android:layout_width="match_parent" 
      android:layout_height="68dp" 
      android:orientation="horizontal" 
      android:id="@+id/panel"> 
      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="68dp" 
       android:orientation="vertical" 
       android:layout_weight="0.8"> 

       <TextView 
        android:id="@+id/footer" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_weight="1" 
        android:textSize="20sp" 
        android:gravity="center_vertical" 
        android:paddingLeft="10dp"/> 
       <TextView 
        android:id="@+id/foooter" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_weight="1" 
        android:textSize="16sp" 
        android:gravity="center_vertical" 
        android:paddingLeft="10dp"/> 

      </LinearLayout> 
      <ImageButton 
       android:layout_width="68dp" 
       android:layout_height="68dp" 
       android:src="@mipmap/playy" 
       android:id="@+id/play" 
       android:background="@null" 
       /> 
      <ImageButton 
       android:layout_width="68dp" 
       android:layout_height="68dp" 
       android:src="@mipmap/queue" 
       android:id="@+id/queue" 
       android:background="@null" 
       /> 
     </LinearLayout> 
      <FrameLayout 
       android:id="@+id/ss" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical" 
       android:background="#ffffff" 
       > 

       <!-- <TextView 
        android:id="@+id/list_main" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_marginTop="?attr/actionBarSize" 
        android:gravity="center" 
        android:text="Main Content" 
        android:clickable="true" 
        android:focusable="false" 
        android:focusableInTouchMode="true" 
        android:textSize="16sp" />--> 

        <LinearLayout android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:orientation="vertical" 
         android:layout_below="@+id/panel"> 

         <LinearLayout 
          android:id="@+id/songThumbnail" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:paddingTop="10dp" 
          android:paddingBottom="10dp" 
          android:gravity="center" 
          android:layout_weight="0.9" 
          android:layout_marginTop="?attr/actionBarSize" 
          > 

          <ImageView android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:id="@+id/album_art" 
           android:src="@mipmap/music" 
           /> 
         </LinearLayout> 


         <LinearLayout 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:orientation="vertical" 
          android:layout_above="@+id/linearLayout" 
          android:layout_alignParentStart="true" 
          > 

          <SeekBar 
           android:id="@+id/songProgressBar" 
           android:layout_width="fill_parent" 
           android:layout_height="wrap_content" 
           android:layout_marginRight="20dp" 
           android:layout_marginLeft="20dp" 
           android:layout_marginBottom="20dp" 

           android:thumb="@mipmap/seek_handler" 
                 android:progressDrawable="@mipmap/img_seekbar_bg" 
           android:paddingLeft="6dp" 
           android:paddingRight="6dp"/> 

          <!-- Timer Display --> 
          <LinearLayout 
           android:id="@+id/timerDisplay" 
           android:layout_above="@id/songProgressBar" 
           android:layout_width="fill_parent" 
           android:layout_height="wrap_content" 
           android:layout_marginRight="20dp" 
           android:layout_marginLeft="20dp" 
           android:layout_marginBottom="10dp"> 
           <!-- Current Duration Label --> 
           <TextView 
            android:id="@+id/songCurrentDurationLabel" 
            android:layout_width="match_parent" 
            android:layout_height="wrap_content" 
            android:layout_weight="1" 
            android:gravity="left" 
            android:textColor="#eeeeee" 
            android:textStyle="bold"/> 
           <!-- Total Duration Label --> 
           <TextView 
            android:id="@+id/songTotalDurationLabel" 
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" 
            android:layout_weight="1" 
            android:gravity="right" 
            android:textColor="#04cbde" 
            android:textStyle="bold"/> 


          </LinearLayout> 
         </LinearLayout> 
         <LinearLayout 
          android:layout_width="fill_parent" 
          android:layout_height="200dp" 
          android:orientation="horizontal" 
          android:gravity="center" 
          android:layout_weight="0.1" 
          android:id="@+id/linearLayout" 
          > 


          <!-- Previous Button --> 
          <ImageButton 
           android:id="@+id/bt_previous" 
           android:src="@mipmap/previous" 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:background="@null" 
           android:layout_weight="2" 
           /> 

          <!-- Backward Button --> 

          <!-- Play Button --> 
          <ImageButton 
           android:id="@+id/bt_play" 
           android:src="@mipmap/playy" 
           android:layout_width="100px" 
           android:layout_height="100px" 
           android:background="@null" 
           android:layout_weight="2"/> 
          <!-- Forward Button --> 

          <!-- Next Button --> 
          <ImageButton 
           android:id="@+id/bt_next" 
           android:src="@mipmap/next" 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:background="@null" 
           android:layout_weight="2" 
           /> 


         </LinearLayout> 
        </LinearLayout> 

      </FrameLayout> 



     </LinearLayout> 
    </com.sothree.slidinguppanel.SlidingUpPanelLayout> 






</RelativeLayout> 

выше мой XML-код для SlidingUpPanel, который используется в моем главном Activity.It имеет две части, основное содержание (обычный экран) и скользящее содержание (которое будет происходить из нижней части экрана). Теперь проблема в том, что эта панель будет отображаться только в основной деятельности. Я хочу отобразить панель для всех моих действий. Окажите мне, как это сделать.Как иметь то же SlidingUpPanel для всех видов деятельности

Пожалуйста, помогите Спасибо .. !!

+0

Есть сдвижную панель в фрагменте и добавить фрагмент, когда вам нужно это в Активность (https://developer.android.com/training/basics/fragments/index.html) –

+0

Предлагаю вам поместить весь файл SlidingPanel в файл макета и вызвать его в каждом действии. Конечно, использование фрагментов жесткое, но более убедительное. –

ответ

0

хорошо, если вы хотите же slidingmenu с одинаковым содержанием во всех ваших действиях, то просто создать активность и коды логики меню скольжения там говорят, что его имя будет BaseActivity затем распространить этот BaseActivity во все другой Активности вашего проекта вместо AppCompatActivity , поэтому вы получите его доступным во всех видах деятельности.

Другой подход был бы Fragment содержащий SlidingMenu, как предложено в комментариях @Veeresh, что также является хорошим вариантом для вас

Ответ на комментарий сделать переменную в вашем MainActivity как этот

public SlidingUpPanelLayout ss; // this is important step , did you followed this in your mainactivity 

его переменный класс, то внутри onCreate метода

ss=(SlidingUpPanelLayout) findViewById(R.id.sliding_layout); 

то в другом activitie S вы можете получить его непосредственно ss

+0

Мне нужно иметь такие же макеты xml для всех видов деятельности, или только один макет xml достаточно для всех видов деятельности? – Androidss

+0

нет, только один макет содержит скользящее меню, которое BaseActivity –

+0

MainActivity расширяет AppCompatActivity, а SecondActivity расширяет MainActivity ............. это правильно? – Androidss

0

Создать свой раздвижную содержание в отдельном макете и надуть его в какой-либо деятельности

LayoutInflater inflater = LayoutInflater.from(getApplicationContext()); 
     LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); 


     View inflatedLayout = inflater.inflate(R.layout.layout1, null, false); 
     inflatedLayout.setLayoutParams(lp); 
Смежные вопросы