当前位置: 首页>>代码示例>>Java>>正文


Java Toolbar.setPadding方法代码示例

本文整理汇总了Java中android.support.v7.widget.Toolbar.setPadding方法的典型用法代码示例。如果您正苦于以下问题:Java Toolbar.setPadding方法的具体用法?Java Toolbar.setPadding怎么用?Java Toolbar.setPadding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.widget.Toolbar的用法示例。


在下文中一共展示了Toolbar.setPadding方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	if(Utils.hasKitKat() && !Utils.hasLollipop()){
		setTheme(R.style.Theme_Document_Translucent);
	}
	setContentView(R.layout.activity_about);

	Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
	mToolbar.setTitleTextAppearance(this, R.style.TextAppearance_AppCompat_Widget_ActionBar_Title);
	if(Utils.hasKitKat() && !Utils.hasLollipop()) {
		//((LinearLayout.LayoutParams) mToolbar.getLayoutParams()).setMargins(0, getStatusBarHeight(this), 0, 0);
		mToolbar.setPadding(0, getStatusBarHeight(this), 0, 0);
	}
	int color = SettingsActivity.getPrimaryColor();
	mToolbar.setBackgroundColor(color);
	setSupportActionBar(mToolbar);
	getSupportActionBar().setDisplayHomeAsUpEnabled(true);
	getSupportActionBar().setTitle(null);
	setUpDefaultStatusBar();

	initControls();
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:24,代码来源:AboutActivity.java

示例2: setupAppBar

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
/**
 * Sets up a top-padding for the given app bar equal to the height of the status bar.
 * This increases the length of the app bar so it fits nicely below the status bar.
 * This method also sets the status bar transparency.
 *
 * @param appBar   Toolbar to set padding to
 * @param activity Activity - current activity
 */
public static void setupAppBar(Toolbar appBar, Activity activity) {
    appBar.setPadding(0, getStatusBarHeight(activity.getResources()), 0, 0);

    SystemBarTintManager tintManager = new SystemBarTintManager(activity);
    tintManager.setStatusBarTintEnabled(true);
    tintManager.setNavigationBarTintEnabled(true);
    tintManager.setTintColor(Color.parseColor("#10000000"));
}
 
开发者ID:digital-voting-pass,项目名称:polling-station-app,代码行数:17,代码来源:Util.java

示例3: onCreate

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // 设置透明状态栏
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        ViewGroup contentFrameLayout = (ViewGroup) findViewById(Window.ID_ANDROID_CONTENT);
        if (contentFrameLayout != null) {
            View parentView = contentFrameLayout.getChildAt(0);
            if (parentView != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                parentView.setFitsSystemWindows(true);
            }
        }
        setContentView(R.layout.activity_main);
        // 获取屏幕方向
        mOrientation = getResources().getConfiguration().orientation;

        // 载入闹钟类型
        AppConstants.AlarmTypeNames = getResources().getStringArray(R.array.alarm_type_names);
        // 更新日期
        DateUtil.updateCurrent();
        // 载入必须服务
        AppConstants.loadGlobalService(this);

        // 开启后台服务
//        if (!Helper.isServiceRunning(this, CalendarService.class.getName())) {
//            AppConstants.DLog("Enter in service...");
            startService(new Intent(this, CalendarService.class));
//        }

        // 初始化闹钟记录
        AlarmRecordMng.initAlarmRecords();
        ShiftsWorkRecordMng.loadDisplayWork();

        mToolbar = (Toolbar) findViewById(R.id.toolbar);
        if (mToolbar != null) {
            int statusHeight = Helper.getStatusHeight(this);
            mToolbar.getLayoutParams().height += statusHeight;
            mToolbar.setPadding(mToolbar.getPaddingLeft(), statusHeight, mToolbar.getPaddingRight(), mToolbar.getPaddingBottom());
            mToolbar.setBackgroundColor(ThemeStyle.Primary);
        }
        mSolarTitle = (TextView) findViewById(R.id.solarTitle);
        if (mSolarTitle != null) {
            mSolarTitle.setOnClickListener(this);
        }

        // 设置右上角的填充菜单
        mToolbar.inflateMenu(R.menu.menu_main);
        mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                return onOptionsItemSelected(item);
            }
        });

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        if (fab != null) {
            fab.setOnClickListener(this);
        }

        // 获取页面资源
        setViewPager();

        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(Intent.ACTION_DATE_CHANGED);
        mDateReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context ctx, Intent intent) {
                onReceiveDate(intent);
            }
        };
        registerReceiver(mDateReceiver, intentFilter);
        WeatherIconUtil.initWeatherNames(getResources().getStringArray(R.array.weather_names));
    }
 
开发者ID:mainh,项目名称:MainCalendar,代码行数:74,代码来源:MainActivity.java

示例4: onSelectorModeEnter

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
public void onSelectorModeEnter() {
    final View rootView = ((Activity) nestedRecyclerView.getContext())
            .findViewById(R.id.root_view);

    final Toolbar toolbar = rootView.findViewById(R.id.toolbar);

    if (theme.darkStatusBarIconsInSelectorMode()) {
        Util.setDarkStatusBarIcons(rootView);
    } else {
        Util.setLightStatusBarIcons(rootView);
    }

    View.OnClickListener onClickListener
            = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            cancelSelectorMode();
        }
    };

    //create selector-toolbar
    final Toolbar selectorToolbar = SelectorModeUtil.getSelectorModeToolbar(
            getContext(), onClickListener,
            NestedRecyclerViewAlbumHolder.this);

    selectorToolbar.setPadding(toolbar.getPaddingLeft(),
            toolbar.getPaddingTop(),
            toolbar.getPaddingRight(),
            toolbar.getPaddingBottom());

    //add selector-toolbar
    ((ViewGroup) toolbar.getParent()).addView(selectorToolbar,
            toolbar.getLayoutParams());

    selectorToolbar.requestLayout();

    //animate selector-toolbar
    selectorToolbar.getViewTreeObserver().addOnGlobalLayoutListener(
            new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    selectorToolbar.getViewTreeObserver().removeOnGlobalLayoutListener(this);

                    selectorToolbar.setTranslationY(-selectorToolbar.getHeight());
                    selectorToolbar.animate().translationY(0);
                }
            });
}
 
开发者ID:kollerlukas,项目名称:Camera-Roll-Android-App,代码行数:50,代码来源:NestedRecyclerViewAlbumHolder.java


注:本文中的android.support.v7.widget.Toolbar.setPadding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。