关于foreground与background的区别


2023年12月23日发(作者:懂车帝)

这时候我们给FrameLayout加上android:background=”@color/colorPrimary”效果如下

我们再给FrameLayout加上android:foreground=”@color/colorAccent”效果变成这样:

} foreground = drawable; if (drawable != null) { setWillNotDraw(false); lback(this); if (eful()) { te(getDrawableState()); } } else { setWillNotDraw(true); } requestLayout(); invalidate(); } } /** * Returns the drawable used as the foreground of this layout. The foreground drawable, * if non-null, is always drawn on top of the children. * * @return A Drawable or null if no foreground was set. */ public Drawable getForeground() { return foreground; } @Override protected void drawableStateChanged() { leStateChanged(); if (foreground != null && eful()) { te(getDrawableState()); } } @Override protected boolean verifyDrawable(Drawable who) { return Drawable(who) || (who == foreground); } @Override public void jumpDrawablesToCurrentState() { awablesToCurrentState(); if (foreground != null) { CurrentState(); } } @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { Changed(w, h, oldw, oldh); foregroundBoundsChanged = true; } @Override public void draw(Canvas canvas) { (canvas); if (foreground != null) { final Drawable foreground = ound; if (foregroundBoundsChanged) { foregroundBoundsChanged = false;

final int w = getRight() - getLeft(); final int h = getBottom() - getTop(); if (foregroundPadding) { nds(, , w - , h - ); } else { nds(0, 0, w, h); } } (canvas); } } @TargetApi(N_OP) @Override public boolean onTouchEvent(MotionEvent e) { if (_INT >= N_OP) { if (ionMasked() == _DOWN) { if (foreground != null) { spot((), ()); } } } return hEvent(e); }}


本文发布于:2024-09-23 18:31:30,感谢您对本站的认可!

本文链接:https://www.17tex.com/fanyi/26614.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:车帝   效果   官网   变成
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议