本文整理匯總了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();
}
}