質問

I have developed app, the header bar of the application get attached in the same row with Sherlock Action Bar when the application installed on the high screen resolution devices above 5 inches (tested on Nexus 5).

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    sActionBar = getSupportActionBar();
    setContentView(R.layout.simple_tabs);
    sContext = this;

    View actionbar = LayoutInflater.from(sContext).inflate(
            R.layout.header_bar, null);
    sActionBar.setDisplayShowCustomEnabled(true);
    sActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    sActionBar.setCustomView(actionbar);


    View homeIcon = findViewById(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ? android.R.id.home
            : R.id.abs__home);

    ((View) homeIcon.getParent()).setVisibility(View.GONE);
    ((View) homeIcon).setVisibility(View.GONE);

    sActionBar.setBackgroundDrawable(getResources().getDrawable(
            R.drawable.actionbar_tabs_selector));

    if (savedInstanceState != null) {
        sActionBar.setSelectedNavigationItem(savedInstanceState
                .getInt("tab"));
    }

    displayUi();

    sActionBar.setSelectedNavigationItem(0);

}



/**
 * Handle UI
 */

public void displayUi() {

    // santosh
    View customView1 = LayoutInflater.from(sContext).inflate(
            R.layout.action_bar_tab_text, null);
    View customView2 = LayoutInflater.from(sContext).inflate(
            R.layout.action_bar_tab_text, null);
    TextView titleTV1 = (TextView) customView1
            .findViewById(R.id.action_custom_title);
    TextView titleTV2 = (TextView) customView2
            .findViewById(R.id.action_custom_title);

    sPager = (ViewPager) ((SherlockFragmentActivity) sContext)
            .findViewById(R.id.pager);

    mTabsAdapter = new TabsAdapter((SherlockFragmentActivity) sContext,
            sActionBar, sPager);

    mTabsAdapter.addTab(sActionBar.newTab().setText(CONTENT1[0]),
            CustomerStatisticsFragment.class, null);

    mTabsAdapter.addTab(sActionBar.newTab().setText(CONTENT1[1]),
            BusinessStatisticsFragment.class, null);


    ActionBar.LayoutParams layoutParams = new LayoutParams(Gravity.CENTER);
    customView1.setLayoutParams(layoutParams);
    customView2.setLayoutParams(layoutParams);

    titleTV1.setText(CONTENT1[0]);
    sActionBar.getTabAt(0).setCustomView(customView1);
    titleTV2.setText(CONTENT1[1]);
    sActionBar.getTabAt(1).setCustomView(customView2);

    final TextView headerText = (TextView) ((SherlockFragmentActivity)     sContext)
            .findViewById(R.id.txtHeader);
    headerText.setText(sContext.getString(R.string.statistics));

}

Screenshot of the issue:

enter image description here

Please suggest me any possible solution.

役に立ちましたか?

解決

im also faced this problem in Nexus 4 (Android 4.4 version) and fixed it like this..

      view = inflater.inflate(R.layout.cus_actionbar_top, null);

    actionbar.setCustomView(view);
    actionbar.setDisplayShowCustomEnabled(true);
    actionbar.setDisplayShowHomeEnabled(false);
    actionbar.setHomeButtonEnabled(false);    


View homeIcon = findViewById(Build.VERSION.SDK_INT >= 
            Build.VERSION_CODES.HONEYCOMB ? android.R.id.home:   R.id.abs__home);
     ((View) homeIcon.getParent()).setVisibility(View.GONE);
     actionbar.setDisplayShowTitleEnabled(false);
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top