마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

Tab Layout 질문 건 [closed]

0 추천

안녕하세요. 언제나 초보적인 질문을 일삼고 있는 추락천사입니다.

오늘은 최대한 혼자 해결해보려고 하다가 이건 더 이상 모르는 부분이 나와버려서...

 

일단, 제 결과입니다.

 

이미지의 한 가운데를 보면 줄이 주~~~욱 가있는 걸 보실 수 있을 겁니다.

이걸 당췌 없앨수가 없네요 -_-;

 

제가 쓴 기본적인 소스입니다.

1. MainActivity.java

package com.example.tabhosttest;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.TabHost;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		TabHost tabHost = (TabHost) findViewById(R.id.tabhost);
		tabHost.setup();
		
		TabHost.TabSpec spec = tabHost.newTabSpec("tag1");
		spec.setContent(R.id.analogclock);
		spec.setIndicator("AnalogColck");
		tabHost.addTab(spec);
		
		spec = tabHost.newTabSpec("tag2");
		spec.setContent(R.id.digitalcolock);
		spec.setIndicator("DigitalClock");
		tabHost.addTab(spec);
		
		tabHost.setCurrentTab(0);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

}

 

2. activity_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    tools:context=".MainActivity" >

    <TabHost 
        android:id="@+id/tabhost"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    	<TabWidget
    	    android:id="@android:id/tabs"
    	    android:layout_width="match_parent"
    	    android:layout_height="match_parent"
    	    android:gravity="fill_horizontal|center_vertical|top" >
</TabWidget>
	    <FrameLayout
    	    android:id="@android:id/tabcontent"
        	android:layout_width="match_parent"
        	android:layout_height="match_parent"
        	android:padding="64dp">
        	<AnalogClock 
        	    android:id="@+id/analogclock"
        	    android:layout_width="match_parent"
                android:layout_height="match_parent"/>
        	<DigitalClock 
        	    android:id="@+id/digitalcolock"
        	    android:layout_width="match_parent"
                android:layout_height="match_parent"/>
    	</FrameLayout>
    </TabHost>
</LinearLayout>

 

이유를 아시는 분은 답글 부탁드립니다,

늦은 밤 주말의 마지막을 행복하게 보내시길... ^^

질문을 종료한 이유: .. 어이없는 실수였군요 .. tabwidget 의 layout_height 를 wrap_content 로 한다는게 그만.. -_-;
추락천사 (150 포인트) 님이 2013년 4월 7일 질문
추락천사님이 2013년 4월 7일 closed
...