촬리의늘솔길

앱만들기.41(CardView) 본문

✍~2022/app(android studio)

앱만들기.41(CardView)

리촬리 2021. 8. 18. 17:14

CardView는 아래와 같이 곡선 테두리와 그림자(음영)를 표시할 수 있는 형태의 레이아웃입니다.

 

implementation 'androidx.cardview:cardview:1.0.0'

를 그래들에 입력

app:cardCornerRadius="20dp"

끝에 둥글게
app:cardElevation="8dp"

z축까지 입체적으로

android:layout_gravity="center"  부모태그 기준으로

 

 

클릭애니메이션 (클릭하면 회색깔로 효과나타남)

즉, 카드뷰 형태의 버튼 디자인도 가능하다는 소리

android:foreground="?android:attr/selectableItemBackground"
android:focusable="true"
android:clickable="true"

 

결과:

 

우.와~

<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView 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"
    app:cardCornerRadius="20dp"
    app:cardElevation="8dp"
    android:layout_margin="16dp"
    android:foreground="?android:attr/selectableItemBackground"
    android:focusable="true"
    android:clickable="true"
    tools:context=".MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_gravity="center"

        >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="나의 카드뷰"
            android:textSize="30sp"
            android:textColor="#000"
            android:layout_gravity="center"
            />
    </LinearLayout>



</androidx.cardview.widget.CardView>

 

 

그래들에 뭐 추가하고 그러는건

https://developer.android.com/guide/topics/ui/layout/cardview?hl=ko 

 

카드 기반 레이아웃 만들기  |  Android 개발자  |  Android Developers

앱에서는 데이터를 비슷한 스타일의 컨테이너에 표시해야 할 때가 많습니다. 이러한 컨테이너는 각 항목의 정보를 보관하기 위해 목록에서 자주 사용됩니다. 시스템은 플랫폼 전반에서 일관된

developer.android.com

이런거 들어가보면 됨.

728x90

'✍~2022 > app(android studio)' 카테고리의 다른 글

aws ec2 + rds + node.js +mysql  (0) 2022.07.31
앱만들기.39(Fragment 간 데이터 전송)  (0) 2021.08.18
앱만들기.38(Table Layout)  (0) 2021.08.18
앱만들기.37(Google Login)  (0) 2021.08.18
앱만들기.36(Check Box)  (0) 2021.08.16