-1
나는 안드로이드에 초보자이며 뷰 페이지를 사용하여 스 와이프 가능한 탭에 대한 데모를 준비하고 성공적으로 준비했습니다. 이제 텍스트 색상을 변경하고 싶습니다. 탭도 선택 style.xml 안드로이드에서 탭의 배경색을 변경하고 뷰 페이지로 안드로이드의 탭 배경을 변경하는 방법
<style name="MyRadioButtonStyle" parent="@android:style/Widget.CompoundButton.RadioButton">
<item name="android:button">@drawable/radio_selected</item>
</style>
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
<item name="colorPrimary">@color/orange</item>
<item name="colorPrimaryDark">@color/orange</item>
<item name="colorAccent">@color/orange</item>
<item name="android:actionBarStyle">@style/MyActionBarTheme</item>
</style>
<style name="MyActionBarTheme" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">@color/orange</item>
<item name="android:textColor">@color/white</item>
</style>
<style name="TabSpecialTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="@android:attr/actionBarTabTextStyle">@style/TabStyle</item>
</style>
<!-- Modify the text color -->
<style name="TabStyle" parent="android:Widget.Holo.Light.ActionBar.TabText.Inverse">
<item name="android:textColor">#F70000</item>
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
main_listing.xml, 내가 그것을 밖으로 정렬 도와주세요
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
mainListing.java
public class MainListingActivity extends FragmentActivity {
ViewPager Tab;
TabsPagerAdapter TabAdapter;
ActionBar actionBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_listing);
TabAdapter = new TabsPagerAdapter(getSupportFragmentManager());
Tab = (ViewPager)findViewById(R.id.pager);
Tab.setOnPageChangeListener(
new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
actionBar = getActionBar();
actionBar.setSelectedNavigationItem(position);
actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#F05423")));
}
});
Tab.setAdapter(TabAdapter);
actionBar = getActionBar();
//Enable Tabs on Action Bar
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
ActionBar.TabListener tabListener = new ActionBar.TabListener(){
@Override
public void onTabReselected(android.app.ActionBar.Tab tab,
FragmentTransaction ft) {
// TODO Auto-generated method stub
}
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
Tab.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(android.app.ActionBar.Tab tab,
FragmentTransaction ft) {
// TODO Auto-generated method stub
}};
//Add New Tab
actionBar.addTab(actionBar.newTab().setText("All").setTabListener(tabListener));
actionBar.addTab(actionBar.newTab().setText("Gents").setTabListener(tabListener));
actionBar.addTab(actionBar.newTab().setText("Ladies").setTabListener(tabListener));
actionBar.addTab(actionBar.newTab().setText("Kids").setTabListener(tabListener));
}
//change tab color..
public void setTabColor(TabHost tabhost) {
for (int i = 0; i < tabhost.getTabWidget().getChildCount(); i++)
tabhost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#ffffff")); //unselected
if (tabhost.getCurrentTab() == 0) {
tabhost.getTabWidget().getChildAt(tabhost.getCurrentTab()).setBackgroundColor(Color.parseColor("#F05423"));
//1st tab selected
} else {
tabhost.getTabWidget().getChildAt(tabhost.getCurrentTab()).setBackgroundColor(Color.parseColor("#F05423"));
}
}
}
hy..ku6의 BHI 변화 나이 아는 .. :( –
너희 지성의 tumne 틈새 방법 bnya 무상 이미 –
mene을 kiye H를 설정 탭 컬러 ISME 색상을 설정할 작풍 bhi는 더 나은 이해를위한 kri를 추가한다 –