안드로이드 개발 질문/답변
(글 수 45,052)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<HorizontalScrollView
android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/scrollView">
<LinearLayout android:id="@+id/linear" android:layout_width="match_parent" android:layout_height="match_parent">
<!-- 항상 레이아웃을 스크롤뷰에 넣은 후 해당 레이아웃에 뷰들을 추가해야한다는 사실 -->
<Button
android:text="Button1"
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></Button>
<Button
android:text="Button2"
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></Button>
<Button
android:text="Button3"
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></Button>
<Button
android:text="Button4"
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></Button>
<Button
android:text="Button5"
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button6"
android:id="@+id/button6"></Button>
<Button
android:text="Button7"
android:id="@+id/button7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></Button>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
이런식으로 xml파일을 구성하고
소스파일에서 버튼 이동을 구현하고 싶습니다.
예를 들어 스크롤뷰 안의 버튼5를 누르면
버튼 5가 스크롤뷰 맨 앞으로 이동되고
뒤에 있던 버튼6이 버튼 5의 자리를 매꾸는 방식으로 구현하려합니다.
다른 분들 질문 보니 스크롤뷰안에서 움직이는건 없고
(어차피 레이아웃 안에 있는 버튼들이니 레이아웃에서 버튼순서 변경이라고 봐도되겠네요.)
일반적으로 margin을 줘서 이동하거나 하시더라구요.
도움 부탁드리겠습니다 (__)