中心标志在行动栏

时间:2015-01-26 09:46:46

标签: android

我正在尝试将应用徽标集中在应用中心。

 MainActivity Code:
    public class ProfileActivity extends ActionBarActivity {
        private SlidingTabLayout slidingTabLayout;
        private ViewPager viewPager;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_profile);
            centreLogo();
            viewPager = (ViewPager) findViewById(R.id.my_pager);

            viewPager.setAdapter(new MyAdapterFrag(getSupportFragmentManager()));

            slidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs);

            // (R.id.sliding_tabs).setDistributeEvenly(true);
            slidingTabLayout.setViewPager(viewPager);
            // viewPager = (ViewPager) findViewById(R.id.pager);
            setUpTabColor();
        }

@Override
    public android.support.v7.app.ActionBar getSupportActionBar() {
        // TODO Auto-generated method stub
        return super.getSupportActionBar();
    }

    private void centreLogo() {

        // TODO Auto-generated method stub

        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowTitleEnabled(false);
        if (findViewById(android.R.id.home) != null) {
            findViewById(android.R.id.home).setVisibility(View.GONE);
        }

        LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        View view = inflator.inflate(R.layout.activity_profile, null);

        ActionBar.LayoutParams params = new ActionBar.LayoutParams(
                ActionBar.LayoutParams.WRAP_CONTENT,
                ActionBar.LayoutParams.WRAP_CONTENT, Gravity.CENTER);
        getSupportActionBar().setDisplayShowCustomEnabled(true);
        getSupportActionBar().setCustomView(view, params);

        getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#F3F3F3")));
    }

    private void setUpTabColor() {
        // TODO Auto-generated method stub
        slidingTabLayout
                .setCustomTabColorizer(new SlidingTabLayout.TabColorizer() {
                    @Override
                    public int getIndicatorColor(int position) {
                        // TODO Auto-generated method stub
                        return ProfileActivity.this.getResources().getColor(
                                R.color.material_blue_grey_800);
                    }

                    @Override
                    public int getDividerColor(int position) {
                        // TODO Auto-generated method stub
                        return ProfileActivity.this.getResources().getColor(
                                R.color.material_deep_teal_200);
                    }
                });
    }

我收到的错误消息如下: 描述资源路径位置类型 ActionBar类型中的方法setCustomView(View,ActionBar.LayoutParams)不适用于参数(View,ActionBar.LayoutParams)

0 个答案:

没有答案