반응형
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"
tools:context=".MainActivity" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@drawable/image01" />
</LinearLayout>
</ScrollView>
</LinearLayout>
</HorizontalScrollView>
</FrameLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_weight="0"
android:gravity="center">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onButton1"
android:text="▲" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onButton2"
android:text="▼" />
</TableRow>
</TableLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
</LinearLayout>
</HorizontalScrollView>
</FrameLayout>
</LinearLayout>
MainActivity
package com.example.a08;
import androidx.appcompat.app.AppCompatActivity;
import android.media.Image;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity {
ImageView iv1;
ImageView iv2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
iv1 = findViewById(R.id.imageView1);
iv2 = findViewById(R.id.imageView2);
button01 = findViewById(R.id.button1);
}
public void onButton1(View v){
showIv1();
}
public void onButton2(View v){
showIv2();
}
private void showIv1(){
iv1.setImageResource(R.drawable.image01);
iv2.setImageResource(0);
}
private void showIv2(){
iv2.setImageResource(R.drawable.image01);
iv1.setImageResource(0);
}
}
반응형
'안드로이드' 카테고리의 다른 글
터치 이벤트 (0) | 2021.10.11 |
---|---|
SMS 입력 화면 만들고 글자 수 표현 (0) | 2021.10.11 |
셰이프 드로어블 - 투명 배경 버튼 (0) | 2021.10.08 |
셰이프 드로어블 - 그라디언트 (0) | 2021.10.08 |
셰이프 드로어블 (0) | 2021.10.08 |