안드로이드 개발자의 창고
[31일차 Android] CardView 본문
출처 : 안드로이드 앱스쿨 2기 윤재성 강사님 수업 PPT
📖 CardView
- 화면에 배치되는 View들을 그룹으로 묶어 관리할 수 있는 View
- CardView 자체에 그림자를 두어 약간 공중에 떠있는 듯한 모습을 만들 수 있다.
주요 속성
속성
|
설명
|
contentPadding
|
CardView 내부의 여백을 설정
|
cardCornerRadius
|
CardView 모서리 부분의 둥근 정도를 설정
|
cardElevation
|
CardView가 공중에 떠있는 정도를 설정
|
예제 코드
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:orientation="vertical"
android:padding="20dp"
tools:context=".MainActivity">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="10dp"
app:cardElevation="10dp"
app:contentPadding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/ic_launcher" />
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
결과
'Computer > Android' 카테고리의 다른 글
[31일차 Android] ListView - ArrayAdapter (0) | 2023.06.14 |
---|---|
[31일차 Android] FloatingActionButton (0) | 2023.06.14 |
[30일차 Android] Bar(ProgressBar, SeekBar, RatingBar) (0) | 2023.06.14 |
[30일차 Android] Chip (0) | 2023.06.14 |
[30일차 Android] CheckedTextView (0) | 2023.06.14 |