下面列出了android.widget.RelativeLayout#setElevation ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private ViewGroup createContentContainer(Context context) {
RelativeLayout contentContainer = new RelativeLayout(context);
ViewGroup.MarginLayoutParams layoutParams = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParams.bottomMargin = layoutParams.leftMargin = layoutParams.topMargin = layoutParams.rightMargin = AndroidUtilities.dp(20);
contentContainer.setLayoutParams(layoutParams);
contentContainer.setElevation(AndroidUtilities.dp(2));
contentContainer.setFocusable(true);
contentContainer.setFocusableInTouchMode(true);
GradientDrawable shape = new GradientDrawable();
shape.setShape(GradientDrawable.RECTANGLE);
int r = AndroidUtilities.dp(6);
shape.setCornerRadii(new float[] { r, r, r, r, r, r, r, r });
if (currentStyle == STYLE_DIALOG) {
shape.setColor(Theme.getColor(Theme.key_dialogBackground));
} else if (currentStyle == STYLE_BLACK) {
shape.setColor(0xf9222222);
} else if (currentStyle == STYLE_THEME) {
shape.setColor(Theme.getColor(Theme.key_windowBackgroundWhite));
}
contentContainer.setBackgroundDrawable(shape);
contentContainer.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
contentContainer.setClipToOutline(true);
return contentContainer;
}
private ViewGroup createContentContainer(Context context) {
RelativeLayout contentContainer = new RelativeLayout(context);
ViewGroup.MarginLayoutParams layoutParams = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParams.bottomMargin = layoutParams.leftMargin = layoutParams.topMargin = layoutParams.rightMargin = AndroidUtilities.dp(20);
contentContainer.setLayoutParams(layoutParams);
contentContainer.setElevation(AndroidUtilities.dp(2));
contentContainer.setFocusable(true);
contentContainer.setFocusableInTouchMode(true);
GradientDrawable shape = new GradientDrawable();
shape.setShape(GradientDrawable.RECTANGLE);
int r = AndroidUtilities.dp(6);
shape.setCornerRadii(new float[] { r, r, r, r, r, r, r, r });
if (currentStyle == STYLE_DIALOG) {
shape.setColor(Theme.getColor(Theme.key_dialogBackground));
} else if (currentStyle == STYLE_BLACK) {
shape.setColor(0xf9222222);
} else if (currentStyle == STYLE_THEME) {
shape.setColor(Theme.getColor(Theme.key_windowBackgroundWhite));
}
contentContainer.setBackgroundDrawable(shape);
contentContainer.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
contentContainer.setClipToOutline(true);
return contentContainer;
}