ActivityMain.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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="5">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/friends"
android:visibility="visible" />
</ScrollView>
</HorizontalScrollView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center"
>
<Button
android:id="@+id/upBut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="UP"
android:onClick="UP"/>
<Button
android:id="@+id/downBut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DOWN"
android:onClick="DOWN"/>
</LinearLayout>
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="5">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/friends"
android:visibility="invisible" />
</ScrollView>
</HorizontalScrollView>
</LinearLayout>
MainActivity.java
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity {
ImageView up;
ImageView down;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
up = (ImageView) findViewById(R.id.up);
down = (ImageView) findViewById(R.id.down);
}
public void UP(View v){
upimage();
}
public void DOWN(View v){
downimage();
}
private void upimage(){
up.setVisibility(View.VISIBLE);
down.setVisibility(View.INVISIBLE);
}
private void downimage(){
up.setVisibility(View.INVISIBLE);
down.setVisibility(View.VISIBLE);
}
}
실행화면
기본 화면
down 버튼 누르면
up 버튼 누르면
'프로그래밍 > 안드로이드 스튜디오' 카테고리의 다른 글
안드로이드 스튜디오 <슬라이딩 메뉴> (0) | 2018.05.03 |
---|---|
안드로이드 스튜디오 < 로그인화면 만들기 > (0) | 2018.05.03 |