안녕하세요.. 탭위젯에 이미지뷰를 3번째 탭에 넣었는데, 이미지뷰를 가동시킨후에
다른탭(1번째탭이나 2번째탭)으로 이동하여도 이미지뷰가 그대로 보이네요..
좀 안보이게 할 수 없을까요
가령, 예를 들자면, 아래 그림과 같이
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
public class TabDemo extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabs=(TabHost)findViewById(R.id.tabhost);
tabs.setup();
TabHost.TabSpec spec=tabs.newTabSpec("tag1");
spec.setContent(R.id.tab1);
spec.setIndicator("시계");
tabs.addTab(spec);
spec=tabs.newTabSpec("tag2");
spec.setContent(R.id.tab2);
spec.setIndicator("버튼");
tabs.addTab(spec);
spec=tabs.newTabSpec("tag3");
spec.setContent(R.id.startFAButtonId);
spec.setIndicator("Start");
tabs.addTab(spec);
this.setupButton();
}
private void setupButton()
{
Button b = (Button)this.findViewById(R.id.startFAButtonId);
b.setOnClickListener(
new Button.OnClickListener() {
public void onClick(View v)
{
parentButtonClicked(v);
}
});
}
private void parentButtonClicked(View v)
{
animate();
}
private void animate()
{
ImageView imgView = (ImageView)findViewById(R.id.imageView);
imgView.setVisibility(ImageView.VISIBLE);
imgView.setBackgroundResource(R.drawable.frame_animation);
AnimationDrawable frameAnimation =
(AnimationDrawable) imgView.getBackground();
if (frameAnimation.isRunning())
{ frameAnimation.stop(); }
else
{
frameAnimation.stop();
frameAnimation.start(); } } }
+++++++++++++++++++++++++++++++++++XML은
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<AnalogClock android:id="@+id/tab1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true" />
</LinearLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="70dip"
>
<TextView android:id="@+id/tab2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="사랑합니다. ^0^ 사랑합니다. ^0^ 사랑합니다. ^0^ 사랑합니다. ^0^ 사랑합니다. ^0^ 사랑합니다. ^0^ 사랑합니다. ^0^ 사랑합니다. ^0^ 사랑합니다. ^0^ 사랑합니다. ^0^ 사랑합니다. ^0^"
/>
</RelativeLayout>
//-----------------------------------------------------------//
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="70dip"
>
<Button
android:id="@+id/startFAButtonId"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="애니메이션 시작" />
<ImageView android:id="@+id/imageView"
android:layout_below="@id/startFAButtonId"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</RelativeLayout>
//-----------------------------------------------------------//
</FrameLayout>
</TabHost>