मैं एक्शनबार शेरलॉक टैब को कस्टमाइज़ करने की कोशिश कर रहा हूं ताकि वे टैब आइकन के नीचे टैब टेक्स्ट प्रदर्शित कर सकें। विषय के बारे में खोज और पढ़ने के बाद, मुझे अभी भी बहुत भाग्य नहीं है।एंड्रॉइड - एक्शनबार शेरलॉक टैब को अनुकूलित करना
यहाँ परिणाम मैं हो रही हैं:
कस्टम tab1 चयनित
कस्टम tab1 चयनित नहीं, मानक tab2 चयनित
यह वही है मैं अब तक है:
अपनी खुद की शैलियों .xml बनाया जहां मैं कुछ एक्शनबार सेटिंग्स बदलता हूं:
<style name="SkoletubeTheme" parent="Theme.Sherlock">
<item name="actionBarSize">@dimen/st__action_bar_default_height</item>
<item name="actionBarTabStyle">@style/Skoletube.TabView</item>
<item name="actionBarTabTextStyle">@style/Skoletube.Tab.Text</item>
</style>
<style name="Skoletube.TabView" parent="Widget.Sherlock.ActionBar.TabView">
<item name="android:background">@drawable/abs__tab_indicator_holo</item>
<item name="android:paddingLeft">6dp</item>
<item name="android:paddingRight">6dp</item>
</style>
<style name="Skoletube.Tab.Text" parent="Widget.Sherlock.ActionBar.TabText">
<item name="android:textAppearance">@android:style/TextAppearance.Medium</item>
<item name="android:textColor">@android:color/primary_text_dark</item>
<item name="android:textSize">10sp</item>
</style>
एक xml ressource जहाँ मैं ActionBar के लिए बदल सकते हैं और कुछ textsettings owerwrite बनाया गया। यहां मैंने एक्शनबार की ऊंचाई बढ़ा दी है, जो बदले में टैब की ऊंचाई बढ़ाती है। मैं भी आदेश टैब में
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Default height of an action bar. -->
<dimen name="st__action_bar_default_height">58dip</dimen>
<!-- Text size for action bar titles -->
<dimen name="ab__action_bar_title_text_size">10dp</dimen>
<!-- Text size for action bar subtitles -->
<dimen name="ab__action_bar_subtitle_text_size">6dp</dimen>
<!-- Top margin for action bar subtitles -->
<dimen name="ab__action_bar_subtitle_top_margin">-3dp</dimen>
<!-- Bottom margin for action bar subtitles -->
<dimen name="ab__action_bar_subtitle_bottom_margin">5dip</dimen>
</resources>
फिर फिटिंग आइकन और पाठ के लिए जगह बनाने के पाठ का आकार कम किया है मैं जहाँ मैं आइकन के नीचे टेक्स्ट रखने का विकल्प टैब का उपयोग करने के लिए के लिए एक कस्टम लेआउट, परिभाषित किया है :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/customTabLayout"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="1"
android:focusable="true"
android:gravity="center"
style="?attr/actionBarTabStyle"
>
<ImageView
android:id="@+id/sk_abs__tab_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="@android:color/transparent"
/>
<com.actionbarsherlock.internal.widget.ScrollingTextView
android:id="@+id/sk_abs__tab_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/sk_abs__tab_icon"
android:layout_alignWithParentIfMissing="true"
android:layout_weight="1"
android:layout_centerHorizontal="true"
android:lines="1"
android:scrollHorizontally="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
style="@style/Skoletube.Tab.Text"
/>
<FrameLayout
android:id="@+id/abs__tab_custom"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:padding="5dip"
android:layout_weight="1"
android:visibility="gone"
/>
बस रिकॉर्ड विशेषता रिश्तेदार लेआउट अंक के लिए शैली के रूप में पारित इस के लिए:
<style name="Widget.Sherlock.ActionBar.TabBar" parent="android:Widget"></style>
तब मैं इस प्रकार है, पहला टैब मेरी कस्टमाइज़ किए गए क्रियान्वयन है मेरे ऐप पर इन परिवर्तनों को लागू किया है, दूसरे टैब मानक कार्यान्वयन है:
final ActionBar actionBar;
actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setDisplayUseLogoEnabled(true);
// Set up tabs
myMediaTab = actionBar.newTab();
myMediaTab.setCustomView(R.layout.skoletube_tab_layout);
ImageView myMediaImg = (ImageView) myMediaTab.getCustomView().findViewById(R.id.sk_abs__tab_icon);
myMediaImg.setImageResource(R.drawable.tab_mymedia);
ScrollingTextView myMediaText = (ScrollingTextView) myMediaTab.getCustomView().findViewById(R.id.sk_abs__tab_txt);
myMediaText.setText("Tab1");
myMediaTab.setTabListener(this);
myMediaTab.setTag("MyMediaTab");
actionBar.addTab(myMediaTab);
myChannelsTab = actionBar.newTab();
myChannelsTab.setIcon(drawable.tab_mychannels);
myChannelsTab.setText("Tab2");
myChannelsTab.setTabListener(this);
myChannelsTab.setTag("myChannelsTab");
actionBar.addTab(myChannelsTab);
जबकि मुझे लगता है कि मैं समाधान के करीब हूँ, मैं मुझे लगता है कि मैंने कहीं एक कदम याद किया है।
स्पष्ट रूप से छवि के नीचे पाठ/नीचे के पीछे नीली बार वहां नहीं होने की आवश्यकता है, लेकिन मुझे यह भी पता नहीं लगाया गया है कि मैं कहां केंद्रित छवि सेट कर सकता हूं (मैं चाहता हूं कि एक टैब होने पर आईएमजी रंग बदल जाए चयनित) और टेक्स्ट रंग। क्या मुझे इमेजव्यू फोकस करने योग्य और इसे उस के माध्यम से संभालने की ज़रूरत है?
मैं अभी भी काफी नया हूं, इसलिए यदि मैंने ऐसा करने के बारे में जाने के लिए बेहतर/बेहतर तरीका है तो मैं यहां जो दृष्टिकोण लेता हूं, वह गलत हो सकता है।
किसी भी सुझाव और विचारों की सराहना करें।
यह वास्तव में मैं क्या समाप्त हो गया है फिर वापस कर रहे हैं। – Line