Java Code Examples for android.widget.RelativeLayout#setElevation()

The following examples show how to use android.widget.RelativeLayout#setElevation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FloatingToolbar.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: FloatingToolbar.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
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;
}