Tab typically located at the top of the screen.
The 'layout' if you want to change, if change is shown below.
('TabWidget' and 'FrameLayout' change of position is the point.
And android: layout_weight = "1" You can help the better.)
※ Example Code
- TapView_Default.java
public class TapView_Default extends TabActivity {
private TabHost m_tabHost = null;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tapview_default_layout);
/** TabHost ID */
m_tabHost= (TabHost)findViewById(android.R.id.tabhost);
TabSpec aaa_TabSpec = m_tabHost.newTabSpec("aaa");
TabSpec bbb_TabSpec = m_tabHost.newTabSpec("bbb");
TabSpec ccc_TabSpec = m_tabHost.newTabSpec("ccc");
aaa_TabSpec.setIndicator("aaa", getResources().getDrawable(R.drawable.games));
aaa_TabSpec.setContent(new Intent(this,test_activity.class));
bbb_TabSpec.setIndicator("bbb", getResources().getDrawable(R.drawable.games));
bbb_TabSpec.setContent(new Intent(this,test_activity.class));
ccc_TabSpec.setIndicator("ccc", getResources().getDrawable(R.drawable.games));
ccc_TabSpec.setContent(new Intent(this,test_activity.class));
/** 탭을 TabHost 에 추가한다 */
m_tabHost.addTab(aaa_TabSpec);
m_tabHost.addTab(bbb_TabSpec);
m_tabHost.addTab(ccc_TabSpec);
/** TabHost 에 포함된 Tab의 색깔 변경가능 */
m_tabHost.getTabWidget().getChildAt(0).setBackgroundColor(Color.parseColor("#534512"));
m_tabHost.getTabWidget().getChildAt(1).setBackgroundColor(Color.parseColor("#4E4E9C"));
m_tabHost.getTabWidget().getChildAt(2).setBackgroundColor(Color.parseColor("#6E8E1C"));
m_tabHost.getTabWidget().setCurrentTab(0);
}
}
- tapview_default_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="vertical">
<TabHost
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@android:id/tabhost">
<LinearLayout
android:id="@+id/LinearLayout01"
android:orientation="vertical"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_weight="1">
</FrameLayout>
<TabWidget
android:id="@android:id/tabs"
android:layout_height="wrap_content"
android:layout_width="fill_parent" >
</TabWidget>
</LinearLayout>
</TabHost>
</LinearLayout>
In addition, inquiries, or questions, please contact us.
(joonryang@gmail.com)
댓글 없음:
댓글 쓰기