1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | tabHost = (TabHost) findViewById(android.R.id.tabhost); tabHost.setup(); tapSpec_1 = tabHost.newTabSpec("TAB_1").setContent(R.id.tab1).setIndicator(null,getResources().getDrawable(R.drawable.setting)); tabHost.addTab(tapSpec_1); tapSpec_2 = tabHost.newTabSpec("TAB_2").setContent(R.id.tab2).setIndicator(null,getResources().getDrawable(R.drawable.temphum)); tabHost.addTab(tapSpec_2); tapSpec_3 = tabHost.newTabSpec("TAB_3").setContent(R.id.tab3).setIndicator(null,getResources().getDrawable(R.drawable.log)); tabHost.addTab(tapSpec_3); tabHost.setCurrentTab(1); RelativeLayout.LayoutParams tvParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); RelativeLayout rl1 = (RelativeLayout) tabHost.getTabWidget().getChildAt(0); rl1.setGravity(Gravity.CENTER_VERTICAL); TextView tv1 = (TextView) rl1.getChildAt(1); tv1.setLayoutParams(tvParams); tv1.setTextAppearance(this, android.R.style.TextAppearance_Medium); tv1.setPadding(10, 0, 10, 0); tv1.setGravity(Gravity.CENTER); RelativeLayout rl2 = (RelativeLayout) tabHost.getTabWidget().getChildAt(1); rl2.setGravity(Gravity.CENTER_VERTICAL); TextView tv2 = (TextView) rl2.getChildAt(1); tv2.setLayoutParams(tvParams); tv2.setTextAppearance(this, android.R.style.TextAppearance_Medium); tv2.setPadding(10, 0, 10, 0); tv2.setGravity(Gravity.CENTER); RelativeLayout rl3 = (RelativeLayout) tabHost.getTabWidget().getChildAt(2); rl3.setGravity(Gravity.CENTER_VERTICAL); TextView tv3 = (TextView) rl3.getChildAt(1); tv3.setLayoutParams(tvParams); tv3.setTextAppearance(this, android.R.style.TextAppearance_Medium); tv3.setPadding(10, 0, 10, 0); tv3.setGravity(Gravity.CENTER); | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="${relativePackage}.${activityClass}" > <TabHost android:id="@android:id/tabhost" android:layout_width="match_parent" android:layout_height="match_parent" > <FrameLayout android:id="@android:id/tabcontent" android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:id="@+id/tab1" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:orientation="vertical" android:paddingTop="40dp" > </LinearLayout> <LinearLayout android:id="@+id/tab2" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:orientation="vertical" android:paddingTop="40dp" > </LinearLayout> <LinearLayout android:id="@+id/tab3" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:orientation="vertical" android:paddingTop="63dp" > </LinearLayout> </FrameLayout> <TabWidget android:id="@android:id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" android:tabStripEnabled="true" > </TabWidget> </TabHost> </LinearLayout> | cs |
'이것저것 > 자바*안드로이드' 카테고리의 다른 글
xml 파싱 (0) | 2016.11.24 |
---|---|
TCP 통신 (0) | 2016.11.18 |
TimePickerDialog (0) | 2016.11.08 |
Okhttp jar (0) | 2016.10.27 |
다이얼로그 안에 텍스트 입력하기 (0) | 2016.10.21 |