當前位置: 首頁>>代碼示例>>Java>>正文


Java WindowInsets類代碼示例

本文整理匯總了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);
}
 
開發者ID:rashikaranpuria,項目名稱:ubiquitous,代碼行數:21,代碼來源:MyWatchFace.java

示例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);
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:26,代碼來源:DrawerLayoutContainer.java

示例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(":");
}
 
開發者ID:changja88,項目名稱:Android_Sunshine_Watch,代碼行數:21,代碼來源:MyWatchFace.java

示例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);
    }
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:21,代碼來源:UILayoutImpl.java

示例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();
}
 
開發者ID:Assassinss,項目名稱:Interessant,代碼行數:18,代碼來源:InsetsDrawerLayout.java

示例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));
}
 
開發者ID:Hitesh880443,項目名稱:SunshineWithWear,代碼行數:17,代碼來源:MyDigitalWatchFace.java

示例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);
}
 
開發者ID:hieple7985,項目名稱:nano-go-ubiquitous,代碼行數:18,代碼來源:WatchFaceService.java

示例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);


}
 
開發者ID:oscarbujinkan,項目名稱:Go-Ubiquitous,代碼行數:22,代碼來源:SunshineWatchFace.java

示例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);
}
 
開發者ID:LadyViktoria,項目名稱:wearDrip,代碼行數:18,代碼來源:HeadingListView.java

示例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);
}
 
開發者ID:DmitryMalkovich,項目名稱:go-ubiquitous,代碼行數:19,代碼來源:SunshineWatchFace.java

示例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);
}
 
開發者ID:jenniferlimtan,項目名稱:UdacityProject6,代碼行數:20,代碼來源:SunshineWatchFace.java

示例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);
}
 
開發者ID:jainkamini,項目名稱:Sunshinewear,代碼行數:20,代碼來源:WatchFace.java

示例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;
}
 
開發者ID:plusCubed,項目名稱:insets-dispatcher,代碼行數:27,代碼來源:InsetsDispatcherHelper.java

示例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);
}
 
開發者ID:f97one,項目名稱:MirageWatch,代碼行數:25,代碼來源:MyWatchFace.java

示例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();
    }
}
 
開發者ID:mobvoi,項目名稱:ticdesign,代碼行數:21,代碼來源:AlertController.java


注:本文中的android.view.WindowInsets類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。