교육/IT

[Android] layout 접었다 폈다 하기

리치라이프 연구소 2023. 3. 29. 14:23
반응형

[Android] layout 접었다 폈다 하기

 

 

 

 

 

1. Gradle에 추가

implementation 'com.ramotion.foldingcell:folding-cell:1.2.3'
반응형

2.xml

<com.ramotion.foldingcell.FoldingCell
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/folding_cell"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
​
        <FrameLayout
            android:id="@+id/cell_content_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/holo_green_dark"
            android:visibility="gone">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="250dp" />
        </FrameLayout>
​
        <FrameLayout
            android:id="@+id/cell_title_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:background="@android:color/holo_blue_dark" />
        </FrameLayout>
​
</com.ramotion.foldingcell.FoldingCell>
반응형

3. 메인코드

 

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
​
    // get our folding cell
    final FoldingCell fc = (FoldingCell) findViewById(R.id.folding_cell);
​
    // attach click listener to folding cell
    fc.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            fc.toggle(false);
        }
    });
}

 

자세한 내용은 아래 링크에서 참고하면 된다.

 

이게 잘 안되면 Table의 view를 gone으로 설정하면 사라졌다 visible로 설정하면 다시 나온다.

 

 

 

출처:https://github.com/Ramotion/folding-cell-android

 

GitHub - Ramotion/folding-cell-android: 📃 FoldingCell is a material design expanding content cell inspired by folding paper

:octocat: 📃 FoldingCell is a material design expanding content cell inspired by folding paper material made by @Ramotion - GitHub - Ramotion/folding-cell-android: 📃 FoldingCell is a material desi...

github.com

 

반응형