سؤال

Actionbar

Please help me!

Now I'm changing to the tab icon from text but I have a problem that is about the photo.

How can I make that delimeter disable in layout? I tried a few ways but didn't work.

and also I want to know how can i set the background when I press the home button to return to main activity.

Please help to figure it out!

هل كانت مفيدة؟

المحلول 2

I sorted two solutions out for making the divider( delimiter) invisible :

1- Use:

 tabHost.getTabWidget().setDividerDrawable(null);

2- Set android:showDividers="none" on TabWidget , like :

<TabWidget
        android:id="@android:id/tabs"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:gravity="bottom"
        android:layout_alignParentBottom="true"
        android:fadingEdge="none"
        android:showDividers="none" >
</TabWidget>

نصائح أخرى

You should create a cutom layout for your tab. In order to show such a delimiter, add a raw View to your xml file as :

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
    <View
            android:id="@+id/dummyview_left"
            android:layout_width="2dp"
            android:layout_height="fill_parent"
            android:layout_alignParentTop="true"
            android:layout_alignParentLeft="true"
            android:background="@color/orange"
            />

    <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"/>

</RelativeLayout>

This Imageview hold the icon for your tab header and the View (dummyview_left) will be the delimiter, you can also change the color of the delimiter to whatever you desire.

Finally I figured it out!! I didn't use TabHost, so I changed my style.xml

this's really simple code for it. just set TabBar style in your style xml file.

also you can change any image for divider.

<style name="TabBar.Kevin" parent="@style/Widget.Sherlock.ActionBar.TabBar">
    <item name="android:divider">@null</item>
</style>

Thanks!!!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top