本文整理汇总了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();
}
示例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"));
}
示例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));
}
示例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);
}
});
}