本文整理了Java中android.widget.PopupWindow.getBackground()
方法的一些代码示例,展示了PopupWindow.getBackground()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。PopupWindow.getBackground()
方法的具体详情如下:
包路径:android.widget.PopupWindow
类名称:PopupWindow
方法名:getBackground
暂无
代码示例来源:origin: square/assertj-android
public PopupWindowAssert hasBackground(Drawable background) {
isNotNull();
Drawable actualBackground = actual.getBackground();
assertThat(actualBackground) //
.overridingErrorMessage("Expected background <%s> but was <%s>.", background,
actualBackground) //
.isSameAs(background);
return this;
}
代码示例来源:origin: com.willowtreeapps/oak-demos
public void setContentWidth(int width) {
Drawable popupBackground = mPopup.getBackground();
if (popupBackground != null) {
popupBackground.getPadding(mTempRect);
mDropDownWidth = mTempRect.left + mTempRect.right + width;
} else {
mDropDownWidth = width;
}
}
代码示例来源:origin: com.willowtreeapps/oak-demos
private int getMaxAvailableHeight(View anchor, int yOffset, boolean ignoreBottomDecorations) {
final Rect displayFrame = new Rect();
anchor.getWindowVisibleDisplayFrame(displayFrame);
final int[] anchorPos = new int[2];
anchor.getLocationOnScreen(anchorPos);
int bottomEdge = displayFrame.bottom;
if (ignoreBottomDecorations) {
Resources res = anchor.getContext().getResources();
bottomEdge = res.getDisplayMetrics().heightPixels;
}
final int distanceToBottom = bottomEdge - (anchorPos[1] + anchor.getHeight()) - yOffset;
final int distanceToTop = anchorPos[1] - displayFrame.top + yOffset;
// anchorPos[1] is distance from anchor to top of screen
int returnedHeight = Math.max(distanceToBottom, distanceToTop);
if (mPopup.getBackground() != null) {
mPopup.getBackground().getPadding(mTempRect);
returnedHeight -= mTempRect.top + mTempRect.bottom;
}
return returnedHeight;
}
代码示例来源:origin: jaredrummler/MaterialSpinner
@Override public void setBackgroundColor(int color) {
backgroundColor = color;
Drawable background = getBackground();
if (background instanceof StateListDrawable) { // pre-L
try {
Method getStateDrawable = StateListDrawable.class.getDeclaredMethod("getStateDrawable", int.class);
if (!getStateDrawable.isAccessible()) getStateDrawable.setAccessible(true);
int[] colors = { Utils.darker(color, 0.85f), color };
for (int i = 0; i < colors.length; i++) {
ColorDrawable drawable = (ColorDrawable) getStateDrawable.invoke(background, i);
drawable.setColor(colors[i]);
}
} catch (Exception e) {
Log.e("MaterialSpinner", "Error setting background color", e);
}
} else if (background != null) { // 21+ (RippleDrawable)
background.setColorFilter(color, PorterDuff.Mode.SRC_IN);
}
popupWindow.getBackground().setColorFilter(color, PorterDuff.Mode.SRC_IN);
}
代码示例来源:origin: com.squareup.assertj/assertj-android
public PopupWindowAssert hasBackground(Drawable background) {
isNotNull();
Drawable actualBackground = actual.getBackground();
assertThat(actualBackground) //
.overridingErrorMessage("Expected background <%s> but was <%s>.", background,
actualBackground) //
.isSameAs(background);
return this;
}
代码示例来源:origin: stackoverflow.com
public static void dimBehind(PopupWindow popupWindow) {
View container;
if (popupWindow.getBackground() == null) {
if (VERSION.SDK_INT >= VERSION_CODES.M){
container = (View) popupWindow.getContentView().getParent();
} else {
container = popupWindow.getContentView();
}
} else {
if (VERSION.SDK_INT >= VERSION_CODES.M) {
container = (View) popupWindow.getContentView().getParent().getParent();
} else {
container = (View) popupWindow.getContentView().getParent();
}
}
Context context = popupWindow.getContentView().getContext();
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
WindowManager.LayoutParams p = (WindowManager.LayoutParams) container.getLayoutParams();
p.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND;
p.dimAmount = 0.3f;
wm.updateViewLayout(container, p);
}
代码示例来源:origin: stackoverflow.com
public static void dimBehind(PopupWindow popupWindow) {
View container;
if (popupWindow.getBackground() == null) {
if (VERSION.SDK_INT >= VERSION_CODES.M){
container = (View) popupWindow.getContentView().getParent();
} else {
container = popupWindow.getContentView();
}
} else {
if (VERSION.SDK_INT >= VERSION_CODES.M) {
container = (View) popupWindow.getContentView().getParent().getParent();
} else {
container = (View) popupWindow.getContentView().getParent();
}
}
Context context = popupWindow.getContentView().getContext();
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
WindowManager.LayoutParams p = (WindowManager.LayoutParams) container.getLayoutParams();
p.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND; // add a flag here instead of clear others
p.dimAmount = 0.3f;
wm.updateViewLayout(container, p);
}
代码示例来源:origin: rocky0116/orderDishes
popupWindow.getBackground().setAlpha(100);
popupWindow.setAnimationStyle(R.style.mypopwindow_anim_style);
popupWindow.showAsDropDown(cartFrame);
代码示例来源:origin: com.willowtreeapps/oak-demos
Drawable background = mPopup.getBackground();
if (background != null) {
background.getPadding(mTempRect);
内容来源于网络,如有侵权,请联系作者删除!