我开发了应用程序,当应用程序安装在 5 英寸以上的高屏幕分辨率设备上(在 Nexus 5 上测试)时,应用程序的标题栏与 Sherlock 操作栏连接在同一行。
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));
}
问题截图:
请建议我任何可能的解决方案。