如何把图标的操作栏中的标签左边栏中、图标、操作、标签

2023-09-12 03:23:07 作者:恋爱周期未满

我现在用的是ActionBar.Tab,他们总是出现在屏幕的左侧。我想提出的活动图标选项卡的左侧,但它总是出现在标签的右侧。我怎样才能把他们的位置,我想要的吗?

I am using the ActionBar.Tab, and they always appear at the left of screen. I want to put the activity icon to the left of tabs, but it always appear at the right of tabs. How can I move their position to where I want?

推荐答案

这里是我的作品就像一个梦想: 在活动我有这样的:

here is what works for me like a dream: in the Activity I have this:

    //hiding default app icon
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowHomeEnabled(false);
    //displaying custom ActionBar
    View mActionBarView = getLayoutInflater().inflate(R.layout.my_action_bar, null);
    actionBar.setCustomView(mActionBarView);
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM)

my_action_bar.xml:

my_action_bar.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/turquoise">

    <ImageButton 
        android:id="@+id/btn_slide"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:background="@null"
        android:scaleType="centerInside"
        android:src="@drawable/btn_slide"
        android:paddingRight="50dp"
        android:onClick="toggleMenu"
        android:paddingTop="4dp"/>
</RelativeLayout>