마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

이미지 뷰에서 갤러리뷰로 변경하려고합니다..

0 추천

현재 이미지뷰에서 사진들이 나오는데 이걸 갤러리뷰로 변경하고싶습니다

고수분들 도와주세요..

int photo0 = intent.getExtras().getInt("cPhoto0");
ImageView imageView0 = findViewById(R.id.Photo1);
ImageView mainView = findViewById(R.id.BigPhoto);
imageView0.setImageResource(photo0);
mainView.setImageResource(photo0);
int photo1 = intent.getExtras().getInt("cPhoto1");
ImageView imageView1 = findViewById(R.id.Photo2);
imageView1.setImageResource(photo1);
int photo2 = intent.getExtras().getInt("cPhoto2");
ImageView imageView2 = findViewById(R.id.Photo3);
imageView2.setImageResource(photo2);
int photo3 = intent.getExtras().getInt("cPhoto3");
ImageView imageView3 = findViewById(R.id.Photo4);
imageView3.setImageResource(photo3);
ImageView line = findViewById(R.id.Line);
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">

    <TextView
        android:id="@+id/cityName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10px"
        android:text="City Name"
        android:textColorLink="@color/colorPrimary"
        android:textSize="20sp"
        android:textStyle="normal|bold" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:orientation="horizontal">

        <ImageView
            android:id="@+id/Photo1"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:padding="5dp"
            android:onClick="changePhoto"
            android:scaleType="fitXY"
            app:srcCompat="@drawable/germany1" />

        <ImageView
            android:id="@+id/Photo2"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:padding="5dp"
            android:onClick="changePhoto"
            android:scaleType="fitXY"
            app:srcCompat="@drawable/germany2" />

        <ImageView
            android:id="@+id/Photo3"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:padding="5dp"
            android:onClick="changePhoto"
            android:scaleType="fitXY"
            app:srcCompat="@drawable/germany3" />

        <ImageView
            android:id="@+id/Photo4"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:padding="5dp"
            android:onClick="changePhoto"
            android:scaleType="fitXY"
            app:srcCompat="@drawable/germany4" />

    </LinearLayout>

    <ImageView
        android:id="@+id/Line"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:srcCompat="@android:color/black" />

    <ImageView
        android:id="@+id/BigPhoto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:srcCompat="@drawable/germany1" />

</LinearLayout>
익명사용자 님이 2018년 10월 30일 질문

1개의 답변

0 추천
GalleryView 샘플 : https://www.journaldev.com/9546/android-gallery-view-example-tutorial

GalleryView 는 deprecate 되었습니다.

 

RecyclerView 와 LinearLayoutManager를 이용하시면 대체 할 수 있습니다.

https://android--examples.blogspot.com/2016/03/android-horizontal-recyclerview-example.html
원조안드로이드 (58,190 포인트) 님이 2018년 10월 30일 답변
...