일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- R1C3
- 크롤링 오류
- 예외
- 숫자형식오류
- 웹브라우저 수용도
- 자바 오류
- 자바 예외
- 자바
- 우아한테크
- 함수 선언
- 배열 3요소
- html
- SQL입문
- 웹 브라우저 전쟁
- HTML역사
- 예제
- 키-값 데이터베이스
- 함수
- 배열 예제
- DoitSQL
- DoIt
- 숫자 형식
- 페이지분석
- dbms
- Doit입문SQL
- 데이터베이스
- DoitSQL입문
- 생성자
- 크롤링
- SQL
Archives
- Today
- Total
반응형
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- R1C3
- 크롤링 오류
- 예외
- 숫자형식오류
- 웹브라우저 수용도
- 자바 오류
- 자바 예외
- 자바
- 우아한테크
- 함수 선언
- 배열 3요소
- html
- SQL입문
- 웹 브라우저 전쟁
- HTML역사
- 예제
- 키-값 데이터베이스
- 함수
- 배열 예제
- DoitSQL
- DoIt
- 숫자 형식
- 페이지분석
- dbms
- Doit입문SQL
- 데이터베이스
- DoitSQL입문
- 생성자
- 크롤링
- SQL
Archives
- Today
- Total
프로그래밍
[Do it! 안드로이드 앱] 자바) 두 개의 이미지뷰에 이미지 번갈아 보여주기 본문
728x90
반응형
도전과제 03
결과화면
디자인
프로젝트 설명
두 개의 이미지뷰룰 한 화면에 보여주고 하나의 이미지를 두 개의 이미지뷰에서 번갈아서 보여준다
뷰 크기보다 이미지가 클시 수직/수평 스크롤 사용이 가능하다
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"
tools:context=".MainActivity">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="300dp">
<ScrollView
android:layout_width="match_parent"
android:layout_height="300dp"
tools:context=".MainActivity">
<ImageView
android:id="@+id/ImgV1"
android:layout_width="match_parent"
android:layout_height="300dp"
android:src="@drawable/rm1"/>
</ScrollView>
</HorizontalScrollView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="▲"
android:id="@+id/BtnUp"
android:layout_gravity="center"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="▼"
android:id="@+id/BtnDown"
android:layout_gravity="center" />
</LinearLayout>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="300dp">
<ScrollView
android:layout_width="match_parent"
android:layout_height="300dp"
tools:context=".MainActivity">
<ImageView
android:id="@+id/ImgV2"
android:layout_width="match_parent"
android:layout_height="300dp"
android:src="@drawable/rm1" />
</ScrollView>
</HorizontalScrollView>
</LinearLayout>
java
package com.sample.doitmission_03;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.ScrollView;
public class MainActivity extends AppCompatActivity {
ImageView imgV1, imgV2;
Button btnUp, btnDown;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imgV1 = findViewById(R.id.ImgV1);
imgV2 = findViewById(R.id.ImgV2);
btnUp = findViewById(R.id.BtnUp);
btnDown = findViewById(R.id.BtnDown);
imgV1.setVisibility(View.VISIBLE);
imgV2.setVisibility(View.INVISIBLE);
btnUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
imgV1.setVisibility(View.VISIBLE);
imgV2.setVisibility(View.INVISIBLE);
}
});
btnDown.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
imgV2.setVisibility(View.VISIBLE);
imgV1.setVisibility(View.INVISIBLE);
}
});
}
}
728x90
반응형
'안드로이드 > Do it! 안드로이드 앱프로그래밍' 카테고리의 다른 글
[Do it! 안드로이드 앱] 자바) 세 개 이상의 화면 만들어 전환하기 (0) | 2022.05.23 |
---|---|
[Do it! 안드로이드 앱] 자바) 로그인 화면과 메뉴 화면 전환하기 (0) | 2022.05.20 |
[Do it! 안드로이드 앱] 자바) 두 종류의 버튼 모양 만들기 (0) | 2022.05.18 |
[Do it! 안드로이드 앱] 자바) SMS 입력 화면 만들고 글자의 수 표시하기 (0) | 2022.05.16 |
[Do it! 안드로이드 앱] 자바) 여러 개의 버튼 추가하기(Toast, Uri) (0) | 2022.05.16 |
Comments