ActionBarSherlock landscape mode

2019-05-29 02:23发布

问题:

I've read a ton of stuff on this actionbar however, i am having problems with it in landscape mode

i want to create a custom view above the tabs

this is my code

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockActivity;

public class MainActivity extends SherlockActivity {
private ActionBar bar;
@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.Theme_Sherlock);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    bar = getSupportActionBar();
    LayoutInflater inflater =       (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View customView = (View)inflater.inflate(R.layout.custom_view, null);
    bar.setDisplayOptions(
            ActionBar.DISPLAY_SHOW_CUSTOM,
            ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME
                    | ActionBar.DISPLAY_SHOW_TITLE);
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setCustomView(customView, new ActionBar.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
}

 @Override
    public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
        getSupportMenuInflater().inflate(R.menu.test_menu, menu);
        return super.onCreateOptionsMenu(menu);
    }
 }

this is the custom view

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minWidth="100dp"
        android:background="#FFFFFFFF"
        android:text="CUSTOMVIEW" />

</LinearLayout>

however this is the result the view is to the left of the buttons, instead of above them is there a way to make it above the buttons?