ActionBarSherlock landscape mode

亡梦爱人 提交于 2019-12-07 19:51:09

问题


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?

来源:https://stackoverflow.com/questions/16002217/actionbarsherlock-landscape-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!