슬라이드 레이어 만들기 (AndroidSlidingUpPanel 라이브러리)

프로그래밍/Android (Java)|2020. 4. 28. 07:36
반응형

소스 출처 및 라이브러리 배포

https://github.com/umano/AndroidSlidingUpPanel



activity_main.xml


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


       <!-- 메인 화면 -->

        <TextView

            android:layout_width="match_parent"

            android:layout_height="match_parent"

            android:gravity="center"

            android:text="Main Content"

            android:textSize="16sp" />


       <!-- 슬라이드 레이어 부분 -->

        <TextView

            android:layout_width="match_parent"

            android:layout_height="match_parent"

            android:gravity="center|top"

            android:text="The Awesome Sliding Up Panel"

            android:textSize="16sp" />


    </com.sothree.slidinguppanel.SlidingUpPanelLayout> 



MainActivity.java


        // 슬라이드 레이어

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

        slidingUpPanelLayout.addPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {

            @Override

            public void onPanelSlide(View panel, float slideOffset) {


            }


            @Override

            public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState previousState, SlidingUpPanelLayout.PanelState newState) {

            //Toast.makeText(getApplicationContext(),newState.name().toString(),Toast.LENGTH_SHORT).show();


                if(newState.name().toString().equalsIgnoreCase("Collapsed")){


                    // 닫혔을때 처리하는 부분


                }else if(newState.name().equalsIgnoreCase("Expanded")){


                    // 열렸을때 처리하는 부분


                }


            }

        }); 



반응형

댓글()