本文整理汇总了Java中android.view.WindowInsets类的典型用法代码示例。如果您正苦于以下问题:Java WindowInsets类的具体用法?Java WindowInsets怎么用?Java WindowInsets使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WindowInsets类属于android.view包,在下文中一共展示了WindowInsets类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onApplyWindowInsets
import android.view.WindowInsets; //导入依赖的package包/类
@Override
public void onApplyWindowInsets(WindowInsets insets) {
super.onApplyWindowInsets(insets);
// Load resources that have alternate values for round watches.
Resources resources = MyWatchFace.this.getResources();
boolean isRound = insets.isRound();
mXOffset = resources.getDimension(isRound
? R.dimen.digital_x_offset_round : R.dimen.digital_x_offset);
float textSize = resources.getDimension(isRound
? R.dimen.digital_text_size_round : R.dimen.digital_text_size);
float textSizeSmall = resources.getDimension(R.dimen.digital_text_size_small);
float textSizeVerySmall = resources.getDimension(R.dimen.digital_text_very_size_small);
mTextPaint.setTextSize(textSize);
dateTextPaint.setTextSize(textSizeSmall);
lineTextPaint.setTextSize(textSizeVerySmall);
mLowTempPaint.setTextSize(mLowTextSize);
mHighTempPaint.setTextSize(mHighTextSize);
}
示例2: DrawerLayoutContainer
import android.view.WindowInsets; //导入依赖的package包/类
public DrawerLayoutContainer(Context context) {
super(context);
minDrawerMargin = (int) (MIN_DRAWER_MARGIN * AndroidUtilities.density + 0.5f);
setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
setFocusableInTouchMode(true);
if (Build.VERSION.SDK_INT >= 21) {
setFitsSystemWindows(true);
setOnApplyWindowInsetsListener(new OnApplyWindowInsetsListener() {
@SuppressLint("NewApi")
@Override
public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
final DrawerLayoutContainer drawerLayout = (DrawerLayoutContainer) v;
lastInsets = insets;
drawerLayout.setWillNotDraw(insets.getSystemWindowInsetTop() <= 0 && getBackground() == null);
drawerLayout.requestLayout();
return insets.consumeSystemWindowInsets();
}
});
setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
shadowLeft = getResources().getDrawable(R.drawable.menu_shadow);
}
示例3: onApplyWindowInsets
import android.view.WindowInsets; //导入依赖的package包/类
@Override
public void onApplyWindowInsets(WindowInsets insets) {
super.onApplyWindowInsets(insets);
// Load resources that have alternate values for round watches.
Resources resources = MyWatchFace.this.getResources();
boolean isRound = insets.isRound();
mXOffset = resources.getDimension(isRound
? R.dimen.digital_text_size_round : R.dimen.digital_text_size);
float textSize = resources.getDimension(isRound
? R.dimen.digital_text_size_round : R.dimen.digital_text_size);
hourPaint.setTextSize(textSize);
minutePaint.setTextSize(textSize);
colonPaint.setTextSize(textSize);
highPaint.setTextSize(textSize);
lowPaint.setTextSize(textSize);
colonWidth = colonPaint.measureText(":");
}
示例4: onApplyWindowInsets
import android.view.WindowInsets; //导入依赖的package包/类
@Override
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mInsets[0] = insets.getSystemWindowInsetLeft();
mInsets[1] = insets.getSystemWindowInsetTop();
mInsets[2] = insets.getSystemWindowInsetRight();
mInsets[3] = insets.getSystemWindowInsetBottom();
post(new Runnable() {
@Override
public void run() {
notifyListener();
}
});
return super.onApplyWindowInsets(insets.replaceSystemWindowInsets(insets.getSystemWindowInsetLeft(), 0,
insets.getSystemWindowInsetRight(), lockHeight ? 0 : insets.getSystemWindowInsetBottom()));
} else {
return super.onApplyWindowInsets(insets);
}
}
示例5: onApplyWindowInsets
import android.view.WindowInsets; //导入依赖的package包/类
@Override
public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
int l = insets.getSystemWindowInsetLeft();
int t = insets.getSystemWindowInsetTop();
int r = insets.getSystemWindowInsetRight();
toolbar.setPadding(l, toolbar.getPaddingTop() + t, 0, 0);
final boolean ltr = recyclerView.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR;
setPadding(getPaddingLeft(), getPaddingTop(), getPaddingEnd() + (ltr ? r : 0),
getPaddingBottom()
);
setOnApplyWindowInsetsListener(null);
return insets.consumeSystemWindowInsets();
}
示例6: onApplyWindowInsets
import android.view.WindowInsets; //导入依赖的package包/类
@Override
public void onApplyWindowInsets(WindowInsets insets) {
super.onApplyWindowInsets(insets);
// Load resources that have alternate values for round watches.
Resources resources = MyDigitalWatchFace.this.getResources();
boolean isRound = insets.isRound();
mXOffset = resources.getDimension(isRound
? R.dimen.digital_x_offset_round : R.dimen.digital_x_offset);
textPaintTime.setTextSize(resources.getDimension(R.dimen.time_text_size));
textPaintTimeBold.setTextSize(resources.getDimension(R.dimen.time_text_size));
textPaintDate.setTextSize(resources.getDimension(R.dimen.date_text_size));
textPaintTemp.setTextSize(resources.getDimension(R.dimen.temp_text_size));
textPaintTempBold.setTextSize(resources.getDimension(R.dimen.temp_text_size));
}
示例7: onApplyWindowInsets
import android.view.WindowInsets; //导入依赖的package包/类
@Override
public void onApplyWindowInsets(WindowInsets insets) {
super.onApplyWindowInsets(insets);
Resources res = WatchFaceService.this.getResources();
boolean isRound = insets.isRound();
float highTempTextSize = res.getDimension(isRound ? R.dimen.round_size_text_high_temp : R.dimen.square_size_text_high_temp);
float lowTempTextSize = res.getDimension(isRound ? R.dimen.round_size_text_low_temp : R.dimen.square_size_text_low_temp);
float textSize = res.getDimension(isRound ? R.dimen.clock_text_size_round : R.dimen.clock_text_size);
float dateTextSize = res.getDimension(isRound ? R.dimen.round_size_text_date : R.dimen.square_size_text_date);
highTempPaint.setTextSize(highTempTextSize);
lowTempPaint.setTextSize(lowTempTextSize);
timePaint.setTextSize(textSize);
datePaint.setTextSize(dateTextSize);
}
示例8: onApplyWindowInsets
import android.view.WindowInsets; //导入依赖的package包/类
@Override
public void onApplyWindowInsets(WindowInsets insets) {
super.onApplyWindowInsets(insets);
// Load resources that have alternate values for round watches.
Resources resources = SunshineWatchFace.this.getResources();
boolean isRound = insets.isRound();
mXOffset = resources.getDimension(isRound
? R.dimen.digital_x_offset_round : R.dimen.digital_x_offset);
float textSize = resources.getDimension(isRound
? R.dimen.digital_text_size_round : R.dimen.digital_text_size);
float textDateSize = resources.getDimension(isRound
? R.dimen.digital_date_text_size_round : R.dimen.digital_date_text_size);
mTextPaint.setTextSize(textSize);
mAlphaTextPaint.setTextSize(textDateSize);
mAlphaTempPaint.setTextSize(textDateSize);
}
示例9: onApplyWindowInsets
import android.view.WindowInsets; //导入依赖的package包/类
@Override public WindowInsets onApplyWindowInsets(final WindowInsets insets) {
heading.setTextColor(-1);
if(insets.isRound()) {
heading.setGravity(Gravity.CENTER_HORIZONTAL);
// Adjust paddings for round devices
if(!hasAdjustedPadding) {
final int padding = heading.getPaddingTop();
heading.setPadding(padding, 2 * padding, padding, padding);
list.setPadding(padding, 0, padding, 0);
hasAdjustedPadding = true;
}
} else {
heading.setGravity(Gravity.START);
}
return super.onApplyWindowInsets(insets);
}
示例10: onApplyWindowInsets
import android.view.WindowInsets; //导入依赖的package包/类
@Override
public void onApplyWindowInsets(WindowInsets insets) {
super.onApplyWindowInsets(insets);
// Load resources that have alternate values for round watches.
Resources resources = SunshineWatchFace.this.getResources();
boolean isRound = insets.isRound();
mTimeXOffset = resources.getDimension(isRound
? R.dimen.digital_time_x_offset_round : R.dimen.digital_time_x_offset);
float timeTextSize = resources.getDimension(isRound
? R.dimen.digital_time_text_size_round : R.dimen.digital_time_text_size);
mTimePaint.setTextSize(timeTextSize);
float dateTextSize = resources.getDimension(isRound
? R.dimen.date_text_size_round : R.dimen.date_text_size);
mDatePaint.setTextSize(dateTextSize);
float temperatureTextSize = resources.getDimension(isRound
? R.dimen.temperature_text_size_round : R.dimen.temperature_text_size);
mTemperaturePaint.setTextSize(temperatureTextSize);
}
示例11: onApplyWindowInsets
import android.view.WindowInsets; //导入依赖的package包/类
@Override
public void onApplyWindowInsets(WindowInsets insets) {
super.onApplyWindowInsets(insets);
// Load resources that have alternate values for round watches.
Resources resources = SunshineWatchFace.this.getResources();
float textSize = resources.getDimension(R.dimen.digital_text_size);
float smallTextSize = resources.getDimension(R.dimen.digital_small_text_size);
float mediumTextSize = resources.getDimension(R.dimen.digital_medium_text_size);
mTimePaint.setTextSize(textSize);
mDatePaint.setTextSize(smallTextSize);
mAmPmPaint.setTextSize(textSize);
mMinTempPaint.setTextSize(mediumTextSize);
mMaxTempPaint.setTextSize(mediumTextSize);
mMinTempPaint.setARGB(240,240,240,240);
mDatePaint.setARGB(240,240,240,240);
}
示例12: onApplyWindowInsets
import android.view.WindowInsets; //导入依赖的package包/类
@Override
public void onApplyWindowInsets(WindowInsets insets) {
super.onApplyWindowInsets(insets);
// Load resources that have alternate values for round watches.
Resources resources = WatchFace.this.getResources();
boolean isRound = insets.isRound();
mXOffset = resources.getDimension(isRound
? R.dimen.digital_x_offset_round : R.dimen.digital_x_offset);
mYOffset = resources.getDimension(isRound
? R.dimen.digital_y_offset_round : R.dimen.digital_y_offset);
float textSize = resources.getDimension(isRound
? R.dimen.digital_text_size_round : R.dimen.digital_text_size);
mTextPaint.setTextSize(textSize);
}
示例13: onApplyWindowInsets
import android.view.WindowInsets; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.KITKAT_WATCH)
public WindowInsets onApplyWindowInsets(@Nullable WindowInsets insets) {
if (insets != null) {
mInsets = new Rect(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
}
for (int i = 0; i < mView.getChildCount(); i++) {
final View child = mView.getChildAt(i);
if (!(child instanceof InsetsDispatchReceiver)) {
InsetsDispatcherLayoutParamsHelper helper = ((InsetsDispatcherLayoutParams) child.getLayoutParams()).getHelper();
if (helper != null) {
applyInsets(mInsets, child, helper.useLeftInset, helper.useTopInset, helper.useRightInset, helper.useBottomInset, helper.insetsUseMargin);
} else {
applyInsets(mInsets, child, false, false, false, false, false);
}
}
}
applyInsets(mInsets, mView, mUseLeftInset, mUseTopInset, mUseRightInset, mUseBottomInset, mInsetsUseMargin);
ViewCompat.postInvalidateOnAnimation(mView);
return insets;
}
示例14: onApplyWindowInsets
import android.view.WindowInsets; //导入依赖的package包/类
@Override
public void onApplyWindowInsets(WindowInsets insets) {
super.onApplyWindowInsets(insets);
// Load resources that have alternate values for round watches.
Resources res = MyWatchFace.this.getResources();
boolean isRound = insets.isRound();
// 時間部分のサイズ
float textSize = res.getDimension(isRound
? R.dimen.digital_text_size_round : R.dimen.digital_text_size);
// 日付部分のサイズ
float dateSize = res.getDimension(isRound ? R.dimen.date_text_size_round : R.dimen.date_text_size_sq);
// バッテリーレベルのサイズ
float battSize = res.getDimension(isRound ? R.dimen.batt_text_size_ro : R.dimen.batt_text_size_sq);
mHourPaint.setTextSize(textSize);
mMinutesPaint.setTextSize(textSize);
mSeparatorPaint.setTextSize(textSize);
mDatePaint.setTextSize(dateSize);
mBattTextPaint.setTextSize(battSize);
}
示例15: setupDecor
import android.view.WindowInsets; //导入依赖的package包/类
private void setupDecor() {
final View decor = mWindow.getDecorView();
final View parent = mWindow.findViewById(R.id.parentPanel);
if (parent != null && decor != null) {
decor.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
@Override
public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) {
if (insets.isRound()) {
// TODO: Get the padding as a function of the window size.
int roundOffset = mContext.getResources().getDimensionPixelOffset(
R.dimen.alert_dialog_round_padding);
parent.setPadding(roundOffset, roundOffset, roundOffset, roundOffset);
}
return insets.consumeSystemWindowInsets();
}
});
decor.setFitsSystemWindows(true);
decor.requestApplyInsets();
}
}