How to implement the Material-design Elevation for Pre-lollipop

前端 未结 7 1382
南旧
南旧 2020-11-27 11:44

Google has shown some nice ways that elevation effect are shown on Lollipop here.

android:elevation=\"2dp\"

for buttons,

an         


        
相关标签:
7条回答
  • 2020-11-27 12:44

    to add @Ranjith Kumar answer

    To add background color to the drawable (example button background color), we need to get drawable programatically.

    first get the drawable

    Drawable drawable = getResources().getDrawable(android.R.drawable.dialog_holo_light_frame);
    

    set the color

    drawable.setColorFilter(new PorterDuffColorFilter(getResources().getColor(R.color.color_primary), PorterDuff.Mode.MULTIPLY));
    

    then set it to the view.

    view.setBackgroundDrawable(drawable);
    

    in case anyone searching.

    0 讨论(0)
提交回复
热议问题