本文整理汇总了Java中android.support.design.R类的典型用法代码示例。如果您正苦于以下问题:Java R类的具体用法?Java R怎么用?Java R使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
R类属于android.support.design包,在下文中一共展示了R类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ScrimInsetsFrameLayout
import android.support.design.R; //导入依赖的package包/类
public ScrimInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.mTempRect = new Rect();
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsFrameLayout, defStyleAttr, R.style.Widget_Design_ScrimInsetsFrameLayout);
this.mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsFrameLayout_insetForeground);
a.recycle();
setWillNotDraw(true);
ViewCompat.setOnApplyWindowInsetsListener(this, new OnApplyWindowInsetsListener() {
public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
if (ScrimInsetsFrameLayout.this.mInsets == null) {
ScrimInsetsFrameLayout.this.mInsets = new Rect();
}
ScrimInsetsFrameLayout.this.mInsets.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
ScrimInsetsFrameLayout.this.onInsetsChanged(ScrimInsetsFrameLayout.this.mInsets);
ScrimInsetsFrameLayout scrimInsetsFrameLayout = ScrimInsetsFrameLayout.this;
boolean z = ScrimInsetsFrameLayout.this.mInsets.isEmpty() || ScrimInsetsFrameLayout.this.mInsetForeground == null;
scrimInsetsFrameLayout.setWillNotDraw(z);
ViewCompat.postInvalidateOnAnimation(ScrimInsetsFrameLayout.this);
return insets.consumeSystemWindowInsets();
}
});
}
示例2: AppBarLayout
import android.support.design.R; //导入依赖的package包/类
public AppBarLayout(Context context, AttributeSet attrs) {
super(context, attrs);
this.mTotalScrollRange = -1;
this.mDownPreScrollRange = -1;
this.mDownScrollRange = -1;
this.mPendingAction = 0;
setOrientation(1);
ThemeUtils.checkAppCompatTheme(context);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AppBarLayout, 0, R.style.Widget_Design_AppBarLayout);
this.mTargetElevation = (float) a.getDimensionPixelSize(R.styleable.AppBarLayout_elevation, 0);
setBackgroundDrawable(a.getDrawable(R.styleable.AppBarLayout_android_background));
if (a.hasValue(R.styleable.AppBarLayout_expanded)) {
setExpanded(a.getBoolean(R.styleable.AppBarLayout_expanded, false));
}
a.recycle();
ViewUtils.setBoundsViewOutlineProvider(this);
this.mListeners = new ArrayList();
ViewCompat.setElevation(this, this.mTargetElevation);
ViewCompat.setOnApplyWindowInsetsListener(this, new OnApplyWindowInsetsListener() {
public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
return AppBarLayout.this.onWindowInsetChanged(insets);
}
});
}
示例3: ForegroundLinearLayout
import android.support.design.R; //导入依赖的package包/类
public ForegroundLinearLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.mSelfBounds = new Rect();
this.mOverlayBounds = new Rect();
this.mForegroundGravity = Opcodes.INVOKE_STATIC_RANGE;
this.mForegroundInPadding = true;
this.mForegroundBoundsChanged = false;
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ForegroundLinearLayout, defStyle, 0);
this.mForegroundGravity = a.getInt(R.styleable.ForegroundLinearLayout_android_foregroundGravity, this.mForegroundGravity);
Drawable d = a.getDrawable(R.styleable.ForegroundLinearLayout_android_foreground);
if (d != null) {
setForeground(d);
}
this.mForegroundInPadding = a.getBoolean(R.styleable.ForegroundLinearLayout_foregroundInsidePadding, true);
a.recycle();
}
示例4: show
import android.support.design.R; //导入依赖的package包/类
void show(@Nullable final InternalVisibilityChangedListener listener, boolean fromUser) {
if (this.mView.getVisibility() != 0 || this.mIsHiding) {
this.mView.clearAnimation();
this.mView.internalSetVisibility(0, fromUser);
Animation anim = AnimationUtils.loadAnimation(this.mView.getContext(), R.anim.design_fab_in);
anim.setDuration(200);
anim.setInterpolator(AnimationUtils.LINEAR_OUT_SLOW_IN_INTERPOLATOR);
anim.setAnimationListener(new AnimationListenerAdapter() {
public void onAnimationEnd(Animation animation) {
if (listener != null) {
listener.onShown();
}
}
});
this.mView.startAnimation(anim);
} else if (listener != null) {
listener.onShown();
}
}
示例5: setCollapsedTextAppearance
import android.support.design.R; //导入依赖的package包/类
void setCollapsedTextAppearance(int resId) {
TypedArray a = this.mView.getContext().obtainStyledAttributes(resId, R.styleable.TextAppearance);
if (a.hasValue(R.styleable.TextAppearance_android_textColor)) {
this.mCollapsedTextColor = a.getColor(R.styleable.TextAppearance_android_textColor, this.mCollapsedTextColor);
}
if (a.hasValue(R.styleable.TextAppearance_android_textSize)) {
this.mCollapsedTextSize = (float) a.getDimensionPixelSize(R.styleable.TextAppearance_android_textSize, (int) this.mCollapsedTextSize);
}
this.mCollapsedShadowColor = a.getInt(R.styleable.TextAppearance_android_shadowColor, 0);
this.mCollapsedShadowDx = a.getFloat(R.styleable.TextAppearance_android_shadowDx, 0.0f);
this.mCollapsedShadowDy = a.getFloat(R.styleable.TextAppearance_android_shadowDy, 0.0f);
this.mCollapsedShadowRadius = a.getFloat(R.styleable.TextAppearance_android_shadowRadius, 0.0f);
a.recycle();
if (VERSION.SDK_INT >= 16) {
this.mCollapsedTypeface = readFontFamilyTypeface(resId);
}
recalculate();
}
示例6: setExpandedTextAppearance
import android.support.design.R; //导入依赖的package包/类
void setExpandedTextAppearance(int resId) {
TypedArray a = this.mView.getContext().obtainStyledAttributes(resId, R.styleable.TextAppearance);
if (a.hasValue(R.styleable.TextAppearance_android_textColor)) {
this.mExpandedTextColor = a.getColor(R.styleable.TextAppearance_android_textColor, this.mExpandedTextColor);
}
if (a.hasValue(R.styleable.TextAppearance_android_textSize)) {
this.mExpandedTextSize = (float) a.getDimensionPixelSize(R.styleable.TextAppearance_android_textSize, (int) this.mExpandedTextSize);
}
this.mExpandedShadowColor = a.getInt(R.styleable.TextAppearance_android_shadowColor, 0);
this.mExpandedShadowDx = a.getFloat(R.styleable.TextAppearance_android_shadowDx, 0.0f);
this.mExpandedShadowDy = a.getFloat(R.styleable.TextAppearance_android_shadowDy, 0.0f);
this.mExpandedShadowRadius = a.getFloat(R.styleable.TextAppearance_android_shadowRadius, 0.0f);
a.recycle();
if (VERSION.SDK_INT >= 16) {
this.mExpandedTypeface = readFontFamilyTypeface(resId);
}
recalculate();
}
示例7: FloatingActionButton
import android.support.design.R; //导入依赖的package包/类
public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.mShadowPadding = new Rect();
ThemeUtils.checkAppCompatTheme(context);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionButton, defStyleAttr, R.style.Widget_Design_FloatingActionButton);
this.mBackgroundTint = a.getColorStateList(R.styleable.FloatingActionButton_backgroundTint);
this.mBackgroundTintMode = parseTintMode(a.getInt(R.styleable.FloatingActionButton_backgroundTintMode, -1), null);
this.mRippleColor = a.getColor(R.styleable.FloatingActionButton_rippleColor, 0);
this.mSize = a.getInt(R.styleable.FloatingActionButton_fabSize, 0);
this.mBorderWidth = a.getDimensionPixelSize(R.styleable.FloatingActionButton_borderWidth, 0);
float elevation = a.getDimension(R.styleable.FloatingActionButton_elevation, 0.0f);
float pressedTranslationZ = a.getDimension(R.styleable.FloatingActionButton_pressedTranslationZ, 0.0f);
this.mCompatPadding = a.getBoolean(R.styleable.FloatingActionButton_useCompatPadding, false);
a.recycle();
this.mImageHelper = new AppCompatImageHelper(this, AppCompatDrawableManager.get());
this.mImageHelper.loadFromAttributes(attrs, defStyleAttr);
this.mImagePadding = (getSizeDimension() - ((int) getResources().getDimension(R.dimen.design_fab_image_size))) / 2;
getImpl().setBackgroundDrawable(this.mBackgroundTint, this.mBackgroundTintMode, this.mRippleColor, this.mBorderWidth);
getImpl().setElevation(elevation);
getImpl().setPressedTranslationZ(pressedTranslationZ);
getImpl().updatePadding();
}
示例8: setErrorEnabled
import android.support.design.R; //导入依赖的package包/类
public void setErrorEnabled(boolean enabled) {
if (this.mErrorEnabled != enabled) {
if (this.mErrorView != null) {
ViewCompat.animate(this.mErrorView).cancel();
}
if (enabled) {
this.mErrorView = new TextView(getContext());
try {
this.mErrorView.setTextAppearance(getContext(), this.mErrorTextAppearance);
} catch (Exception e) {
this.mErrorView.setTextAppearance(getContext(), R.style.TextAppearance_AppCompat_Caption);
this.mErrorView.setTextColor(ContextCompat.getColor(getContext(), R.color.design_textinput_error_color_light));
}
this.mErrorView.setVisibility(4);
ViewCompat.setAccessibilityLiveRegion(this.mErrorView, 1);
addIndicator(this.mErrorView, 0);
} else {
this.mErrorShown = false;
updateEditTextBackground();
removeIndicator(this.mErrorView);
this.mErrorView = null;
}
this.mErrorEnabled = enabled;
}
}
示例9: setCounterEnabled
import android.support.design.R; //导入依赖的package包/类
public void setCounterEnabled(boolean enabled) {
if (this.mCounterEnabled != enabled) {
if (enabled) {
this.mCounterView = new TextView(getContext());
this.mCounterView.setMaxLines(1);
try {
this.mCounterView.setTextAppearance(getContext(), this.mCounterTextAppearance);
} catch (Exception e) {
this.mCounterView.setTextAppearance(getContext(), R.style.TextAppearance_AppCompat_Caption);
this.mCounterView.setTextColor(ContextCompat.getColor(getContext(), R.color.design_textinput_error_color_light));
}
addIndicator(this.mCounterView, -1);
if (this.mEditText == null) {
updateCounter(0);
} else {
updateCounter(this.mEditText.getText().length());
}
} else {
removeIndicator(this.mCounterView);
this.mCounterView = null;
}
this.mCounterEnabled = enabled;
}
}
示例10: updateCounter
import android.support.design.R; //导入依赖的package包/类
private void updateCounter(int length) {
boolean wasCounterOverflowed = this.mCounterOverflowed;
if (this.mCounterMaxLength == -1) {
this.mCounterView.setText(String.valueOf(length));
this.mCounterOverflowed = false;
} else {
this.mCounterOverflowed = length > this.mCounterMaxLength;
if (wasCounterOverflowed != this.mCounterOverflowed) {
this.mCounterView.setTextAppearance(getContext(), this.mCounterOverflowed ? this.mCounterOverflowTextAppearance : this.mCounterTextAppearance);
}
this.mCounterView.setText(getContext().getString(R.string.character_counter_pattern, new Object[]{Integer.valueOf(length), Integer.valueOf(this.mCounterMaxLength)}));
}
if (this.mEditText != null && wasCounterOverflowed != this.mCounterOverflowed) {
updateLabelState(false);
updateEditTextBackground();
}
}
示例11: PanesBottomSheetBehavior
import android.support.design.R; //导入依赖的package包/类
/**
* Default constructor for inflating BottomSheetBehaviors from layout.
*
* @param context The {@link Context}.
* @param attrs The {@link AttributeSet}.
*/
public PanesBottomSheetBehavior(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.BottomSheetBehavior_Layout);
TypedValue value = a.peekValue(R.styleable.BottomSheetBehavior_Layout_behavior_peekHeight);
if (value != null && value.data == PEEK_HEIGHT_AUTO) {
setPeekHeight(value.data);
} else {
setPeekHeight(a.getDimensionPixelSize(
R.styleable.BottomSheetBehavior_Layout_behavior_peekHeight, PEEK_HEIGHT_AUTO));
}
setSkipCollapsed(a.getBoolean(R.styleable.BottomSheetBehavior_Layout_behavior_skipCollapsed,
false));
a.recycle();
ViewConfiguration configuration = ViewConfiguration.get(context);
mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
}
示例12: passwordToggleHasContentDescription
import android.support.design.R; //导入依赖的package包/类
/**
* Returns a matcher that matches TextInputLayouts with non-empty content descriptions for the
* password toggle.
*/
public static Matcher<View> passwordToggleHasContentDescription() {
return new TypeSafeMatcher<View>(TextInputLayout.class) {
@Override
public void describeTo(Description description) {
description.appendText(
"TextInputLayout has non-empty content description" + "for password toggle.");
}
@Override
protected boolean matchesSafely(View view) {
TextInputLayout item = (TextInputLayout) view;
// Reach in and find the password toggle since we don't have a public API
// to get a reference to it
View passwordToggle = item.findViewById(R.id.text_input_password_toggle);
return !TextUtils.isEmpty(item.getPasswordVisibilityToggleContentDescription())
&& !TextUtils.isEmpty(passwordToggle.getContentDescription());
}
};
}
开发者ID:material-components,项目名称:material-components-android,代码行数:24,代码来源:TextInputLayoutMatchers.java
示例13: doesNotShowPasswordToggle
import android.support.design.R; //导入依赖的package包/类
/** Returns a matcher that matches TextInputLayouts with non-displayed password toggles */
public static Matcher<View> doesNotShowPasswordToggle() {
return new TypeSafeMatcher<View>(TextInputLayout.class) {
@Override
public void describeTo(Description description) {
description.appendText("TextInputLayout shows password toggle.");
}
@Override
protected boolean matchesSafely(View item) {
// Reach in and find the password toggle since we don't have a public API
// to get a reference to it
View passwordToggle = item.findViewById(R.id.text_input_password_toggle);
return passwordToggle.getVisibility() != View.VISIBLE;
}
};
}
开发者ID:material-components,项目名称:material-components-android,代码行数:18,代码来源:TextInputLayoutMatchers.java
示例14: passwordToggleIsNotChecked
import android.support.design.R; //导入依赖的package包/类
/** Returns a matcher that matches TextInputLayouts with non-displayed password toggles */
public static Matcher<View> passwordToggleIsNotChecked() {
return new TypeSafeMatcher<View>(TextInputLayout.class) {
@Override
public void describeTo(Description description) {
description.appendText("TextInputLayout has checked password toggle.");
}
@Override
protected boolean matchesSafely(View item) {
// Reach in and find the password toggle since we don't have a public API
// to get a reference to it
CheckableImageButton passwordToggle = item.findViewById(R.id.text_input_password_toggle);
return !passwordToggle.isChecked();
}
};
}
开发者ID:material-components,项目名称:material-components-android,代码行数:18,代码来源:TextInputLayoutMatchers.java
示例15: clickPasswordToggle
import android.support.design.R; //导入依赖的package包/类
/** Toggles password. */
public static ViewAction clickPasswordToggle() {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return ViewMatchers.isAssignableFrom(TextInputLayout.class);
}
@Override
public String getDescription() {
return "Clicks the password toggle";
}
@Override
public void perform(UiController uiController, View view) {
TextInputLayout textInputLayout = (TextInputLayout) view;
// Reach in and find the password toggle since we don't have a public API
// to get a reference to it
View passwordToggle = textInputLayout.findViewById(R.id.text_input_password_toggle);
passwordToggle.performClick();
}
};
}