대기업을 향한 디벨롭 블로그

RecyclerView , Dialog , WebView 응용하기 본문

나는안드로이드개발자

RecyclerView , Dialog , WebView 응용하기

MHY.PRO 2022. 6. 16. 19:24

지금까지 공부하며 RecyclerView , Dialog , WebView를 사용하여 간단한 예제를 만들었다.

 

 

이렇게 9명의 프로필이있다. 이 프로필은 RecyclerView 에서 GridLayout으로 만들어보았다.

 

<?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:id="@+id/mainView"
    android:layout_width="match_parent"
    android:layout_height="219dp"
    android:orientation="vertical"
    android:gravity="center"
    tools:ignore="OnClick"
    android:background="@drawable/ripple"
    android:backgroundTint="#2DEC4CC5"
    android:clickable="true"
    android:focusable="true"
    >

    <de.hdodenhof.circleimageview.CircleImageView
        android:id="@+id/profile_image"
        android:layout_width="130dp"
        android:layout_height="100dp"
        android:src="@mipmap/ic_launcher"
        />

    <TextView
        android:id="@+id/name"
        android:layout_marginTop="20dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="이새롬"
        android:textSize="23sp"
        />

</LinearLayout>

 

안에 들어가는 item의 xml이다. 이미지는 CircleImage라이브러리를 사용하였다.

 

https://mhypro.tistory.com/37

 

오픈라이브러리 CircleImageView 만들기

CircleImageView를 한번 적용시켜 프로필 이미지를 만들어보겠습니다. CircleImageView는 사진을 동그랗게 만들어준다. 먼저 https://github.com/hdodenhof/CircleImageView 공식사이트에 들어가서 살펴보자. Git..

mhypro.tistory.com

 

요소하나를 클릭하면 그에대한 정보가 Dialog로 나타난다.

 

사진과 그룹,이름 그리고 버튼2개의 요소가있다. 버튼은 instagram버튼과 officical버튼이있다. 

instagram버튼을 누르면 WebView가 띄어지면서 송하영님의 인스타그램으로 연결된다.

 

항상웹뷰를 만들때는 onBackPressed함수인 뒤로가기버튼을 재정의 해주어야된다. 그래야 웹에서 뒤로가기가 먹힌다.

 

그리고 instagram밑에있는 official fromis_9버튼은 official버튼으로 공식홈페이지가 뜨게된다. 

 

심심해서 한번만들어봤다. 다음은 Custom명함만드는 앱을 만들어 볼까 생각중이다. 이렇게 계속 만들어야 실력이 좋아진다. 백날 코드공부만 해봤자 도움안됨