728x90

안드로이드 어플에서 이미지가 수평으로 일정시간후 자동으로 화면이 회전되는 CarouselView 를 검색하여 https://github.com/sayyam/carouselview 이 있는 걸 다운로드 해서 테스트해보고 적어둔다.


위 예제는 Web에 올려진 이미지를 Picasso 이미지 라이브러리를 이용하여 보여주는 것과 Drawable 폴더에 있는 이미지를 보여주는 것을 하나의 화면에서 보여주고 있다.


이미지 라이브러리에 대한 자세한 설명은 http://gun0912.tistory.com/17  와 http://gun0912.tistory.com/19 를 참조하면 도움이 많이 된다.


Web 에서 가져온 이미지의 경우 잔상이 좀 남아서 약간 눈에 거슬려보이기는 하지만 기능은 잘 동작된다.

CarouselView 라이브러리가 기능적으로 편리하게 사용하도록 되어 있는거 같다.


아래 내용은 이해하기 쉽게 용어를 변경하고 기능을 테스트했다.

이미지 롤링 보여주기 용도로는 편하고 좋은거 같은데 달력을 carousel 하기에는 적합하지 않은 거 같아서 다른 걸 추가로 테스트 해보려고 한다.


앱 build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "25.0.0"

    defaultConfig {
        applicationId "com.tistory.link2me.carouselview"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.2.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.synnapps:carouselview:0.0.9'
    compile 'com.squareup.picasso:picasso:2.5.2'  // 이미지 라이브러리
    compile 'com.android.support:recyclerview-v7:23.2.1' // ListView 개선 버전
    compile "com.android.support:cardview-v7:23.2.1"

}


AndroidManifest.xml 에 추가할 사항

<uses-permission android:name="android.permission.INTERNET" />


Layout xml


 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center">

    <ImageView
        android:id="@+id/fruitImageView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scaleType="centerCrop" />

    <TextView
        android:id="@+id/labelTextView"
        style="@style/TextView.Label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</RelativeLayout>



MainActivity.java

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;
import com.synnapps.carouselview.CarouselView;
import com.synnapps.carouselview.ImageListener;
import com.synnapps.carouselview.ViewListener;

public class MainActivity extends AppCompatActivity {
    CarouselView localCarouselView;
    TextView localCarouselLabel;
    String[] TitleNames = {"Orange", "Grapes", "Strawberry", "Cherry", "Apricot"};
    int[] localImages = {R.drawable.image_1,
                          R.drawable.image_2,
                          R.drawable.image_3,
                          R.drawable.image_4,
                          R.drawable.image_5
    };

    CarouselView webCarouselView;
    TextView webCarouselLabel;
    String[] webImageURLs = {
            Value.IPADDRESS + "/img_01.jpg",
            Value.IPADDRESS + "/img_02.jpg",
            Value.IPADDRESS + "/img_03.jpg",
            Value.IPADDRESS + "/img_04.jpg",
            Value.IPADDRESS + "/img_05.jpg"
    };

    Button pauseButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initView();
    }

    private void initView(){

        webCarouselLabel = (TextView) findViewById(R.id.webCarouselLabel);
        // Web 서버 URL 이미지 롤링배너로 보여주기
        webCarouselView = (CarouselView) findViewById(R.id.webCarouselView);
        webCarouselView.setPageCount(webImageURLs.length);
        webCarouselView.setImageListener(new ImageListener() {
            @Override
            public void setImageForPosition(int position, ImageView imageView) {
                Picasso.with(getApplicationContext())
                        .load(webImageURLs[position])
                        .placeholder(localImages[0])
                        .error(localImages[3])
                        .fit().centerCrop()
                        .into(imageView);
            }
        });
        webCarouselView.setIndicatorGravity(Gravity.CENTER_HORIZONTAL|Gravity.BOTTOM);

        localCarouselLabel = (TextView) findViewById(R.id.localCarouselLabel);
        // drawable 이미지 롤링배너 보여주기
        localCarouselView = (CarouselView) findViewById(R.id.localCarouselView);
        localCarouselView.setPageCount(localImages.length);
        localCarouselView.setSlideInterval(4000);
        localCarouselView.setViewListener(new ViewListener() {
            @Override
            public View setViewForPosition(int position) {
                View customView = getLayoutInflater().inflate(R.layout.view_custom, null);

                TextView labelTextView = (TextView) customView.findViewById(R.id.labelTextView);
                ImageView fruitImageView = (ImageView) customView.findViewById(R.id.fruitImageView);

                fruitImageView.setImageResource(localImages[position]);
                labelTextView.setText(TitleNames[position]);

                localCarouselView.setIndicatorGravity(Gravity.CENTER_HORIZONTAL|Gravity.TOP);

                return customView;
            }
        });

        pauseButton = (Button) findViewById(R.id.pauseButton);
        pauseButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                webCarouselView.pauseCarousel();
                localCarouselView.reSetSlideInterval(0);
            }
        });
    }
}


위 테스트에 사용한 소스코드중에서 필요한 것만 발췌했다.


carouselview_ex1.zip



블로그 이미지

Link2Me

,
728x90

기사 전문은 http://news.hankyung.com/article/2017103082191에 있고 일부 기사만 발췌하여 적었다.


구리~포천 간 민자고속도로 개통 4개월을 맞은 30일 경기 포천시가 산업단지 분양률이 높아지고 관광객이 증가하는 등 경기 북부권의 기업 및 관광 중심지로 떠오르고 있다.

김종천 포천시장(사진)은 30일 한국경제신문과의 인터뷰에서 “포천시가 민자도로 개통 이후 기업인과 관광객이 찾는 활기찬 도시로 변화하고 있다”며 “도내 최하위권인 시세를 5년 내 10위권 수준으로 높이겠다”고 강조했다.
 
민자고속도로 포천나들목에 인접해 있는 용정산단은 민자도로 개통 전 40%에 불과했던 분양률이 77%로 높아졌다. 서울 잠실에서 30분 내 도달할 수 있는 교통 여건과 부지가격이 ㎡당 119만원으로 의정부 등 인근 지역 산단에 비해 80만~100만원가량 저렴하기 때문이다. 김 시장은 “허브아일랜드를 찾는 관광객이 월평균 6만 명에서 10% 정도 늘었다”며 “민자도로 개통이 분양률 상승과 관광 활성화에 기여하고 있다”고 소개했다.


포천시는 민자도로 개통을 계기로 기업도시 육성과 한탄강 일대 관광지 개발 등 지역발전 전략을 마련했다. 김 시장은 “95만㎡ 부지에 100개 기업을 유치할 용정산단은 77개 기업이 입주를 결정했고, 장자·에코그린산단 등의 분양률은 입주기업이 늘면서 60%대로 올라섰다”고 소개했다. 시는 최근 들어 기업들의 입주문의가 늘자 8000억원을 들여 50만㎡ 규모의 K-디자인밸리산단을 내년 12월 착공 목표로 추진하기로 했다.


민자도로가 개통된 이후 포천을 찾는 관광객이 늘면서 지역경제에 활력이 되고 있다. 김 시장은 “인천공항에서 자동차로 2시간30분 걸리던 것이 지금은 한 시간으로 줄어 한탄강 둘레길(영북면 부소천~비둘기낭 폭포, 6.2㎞)과 허브아일랜드 등에 동남아시아 관광객이 많이 찾고 있다”며 “연평균 780만 명인 관광객이 올해 10% 정도 늘 것”이라고 설명했다.

김 시장은 관광객 유치를 위해 2019년까지 국내 유일의 현무암 협곡이 있는 한탄강 관광지 일대에 548억원을 투자해 개발하기로 했다. 주상절리길, 생태관광단지 등 6개 한탄강 관광테마사업을 추진한다. 영중면 힐마루관광레저 조성사업 등 20여 개 관광지도 개발하기로 했다. 김 시장은 “포천을 경기북부권 관광의 핵심지로 조성하기 위한 것”이라며 “신평~가양 간 도로 확·포장과 자작~어룡 도로 개설 등 6~7개 사업을 추진해 산단과 관광지를 활성화하겠다”고 강조했다.


블로그 이미지

Link2Me

,