내 탭으로 디자인을 설정하는 데 문제가 있습니다. 그래서 tabHost에 추가하는 각 tabspec에 대한 selector를 만들었습니다.Android 탭 홈 탭 배경의 높이가 작음
public class TabLayouts extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tabhost);
TabHost tabHost = getTabHost();
tabHost.getTabWidget().setStripEnabled(false);
TabSpec latest = tabHost.newTabSpec(getString(R.string.latest_title));
tabHost.setBackgroundResource(R.drawable.tabbar);
// setting Title and Icon for the Tab
latest.setIndicator(getString(R.string.latest_title), getResources().getDrawable(R.drawable.latest_albums_sel));
Intent latestAlbums = new Intent(this, LatestAlbums.class);
latest.setContent(latestAlbums);
TabSpec favorites = tabHost.newTabSpec(getString(R.string.favorites_title));
favorites.setIndicator(getString(R.string.favorites_title), getResources().getDrawable(R.drawable.favorites_sel));
Intent favoritesInt = new Intent(this, Favorites.class);
favorites.setContent(favoritesInt);
TabSpec downloaded = tabHost.newTabSpec(getString(R.string.downloaded_title));
downloaded.setIndicator(getString(R.string.downloaded_title), getResources().getDrawable(R.drawable.downloaded_sel));
Intent downloadedIntent = new Intent(this, Downloaded.class);
downloaded.setContent(downloadedIntent);
tabHost.addTab(latest);
tabHost.addTab(favorites);
tabHost.addTab(downloaded);
}
}
그리고 내 선택기 중 하나 : 그래서 여기
내 탭 활동 : 여기처럼 보이는 방법이다
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- PRESSED TAB -->
<item android:top="0dp" android:left="0dp" android:right="0dp" android:bottom="0dp"
android:state_pressed="true"
android:drawable="@drawable/menu3_pr"
/>
<!-- INACTIVE TABS -->
<item android:top="0dp" android:left="0dp" android:right="0dp" android:bottom="0dp"
android:state_selected="false"
android:state_focused="false"
android:state_pressed="false"
android:drawable="@drawable/menu3_nr"
/>
<!-- ACTIVE TAB -->
<item android:top="0dp" android:left="0dp" android:right="0dp" android:bottom="0dp"
android:state_selected="true"
android:state_focused="false"
android:state_pressed="false"
android:drawable="@drawable/menu3_pr"
/>
<!-- SELECTED TAB -->
<item android:top="0dp" android:left="0dp" android:right="0dp" android:bottom="0dp"
android:state_focused="true"
android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/menu3_pr"
/>
</selector>
그리고 내 tabhost 레이아웃 :
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:background="@drawable/tabbar"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
android:background="@drawable/background"
android:layout_above="@android:id/tabs"
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="match_parent"/>
<TabWidget
android:showDividers="none"
android:layout_alignParentBottom="true"
android:id="@android:id/tabs"
android:scaleY="0.8"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
</TabHost>
아무도 내가이 문제를 해결할 수 있도록 도와 줄 수 있습니까?
도움이 될만한 정보가 있으면 [link] (https://github.com/AdilSoomro/Iphone-Tab-in-Android)를 참조하십시오. –