|
- activity.setContentView(loadlayout{
]- P \2 a6 [ a# W- N0 M - LinearLayout;. X# X3 D8 Q0 H+ J, j \) w/ j
- gravity="center";. x3 ?) @; i8 w
- orientation="vertical";
/ g0 E6 p1 p2 Y* N- g - layout_width="fill";: T; ]* `/ |' |# r& C
- layout_height="fill";) r: ~' k0 o+ D$ ?( v5 T
- {
! \- z6 L* {, P0 o' w! j- q! }1 l) W# q - FrameLayout;
6 h- q/ O$ A) I" _+ A( t5 |! L7 g - layout_height=1080*0.35;
& L% b6 G: Y- z3 ?5 j - layout_width=1920*0.35;
3 m5 o" \+ M1 F {; | - {1 B ]" J+ \0 H0 E' c& J7 i
- ImageView;- U7 m# @0 v- f0 F r
- layout_height="fill";
- Y! n1 f0 m3 k! O% ]. p) j- y - layout_width="fill";# ]' h9 J; L f' f4 P3 n2 [+ ^# b
- src="https://api.vvhan.com/api/bing";
& s7 c- O/ {* ^ - layout_margin="5dp";
& J/ Y, @+ V L- k - };
2 Z3 b+ b( K% P. h - {
6 B! }+ c: S X - LinearLayout;
: i6 r, d" P! W$ U - id="相框";- M; ?: S5 X q& X& j
- layout_height=1080*0.35;
4 e; N, f5 y2 l6 Y x - layout_width=1920*0.35;3 q6 ~6 {3 p" r9 S
- };
2 f: G/ [9 Y0 b$ k W2 `8 Y6 B - };
5 m& L# ^. N# @9 n2 N5 l& _ - })
' W$ E& B; Y* K5 E* G9 t7 {
% R$ T/ h1 P. z' b! @6 A- ; Z5 t% A, q$ L8 Q9 z& G
2 {4 B# v+ X; @% ^- function 边框(view,宽度,阴影,颜色,阴影颜色,外圆角,内圆角)* y8 |! V2 m0 g& c- h
- import "android.graphics.*"* ?) ^1 X! s3 R1 Y$ V& t
- import "android.graphics.Paint$Cap"
# }" B# d' Z1 K" k+ Q, F* B' c - local scale = activity.getResources().getDisplayMetrics().scaledDensity$ X3 L9 h# Z7 x7 z4 L/ G
- function dp(dpValue)
5 q& ~7 k4 z! A( S/ R5 P - return dpValue * scale + 0.53 f4 u0 y, {' _% B$ ]5 ]5 m
- end% J6 c% F2 l+ Q8 f
- $rectf=RectF()9 Y( Q3 P. g# D( ]' \9 A
- $path1=Path()
/ U! D6 m" A2 s) j9 c - $path2=Path()
" y- X! Q4 H1 x4 o/ w - $画布=LuaDrawable(function(画布,画笔)
: j7 @; a, f- Q! f" V7 ~: [ - rectf.set((阴影 or dp(2))+(宽度 or dp(5)),(阴影 or dp(2))+(宽度 or dp(5)),画布.width-((阴影 or dp(2))+(宽度 or dp(5))),画布.height-((阴影 or dp(2))+(宽度 or dp(5)))). K( y4 ]- p* o5 L, u5 q3 e2 ?
- path1.addRoundRect(rectf,内圆角 or dp(2.5),内圆角 or dp(2.5),Path.Direction.CW)
' h9 T, s4 ~' n! y$ s! _+ W: t - rectf.set((阴影 or dp(2)),(阴影 or dp(2)),画布.width-(阴影 or dp(2)),画布.height-(阴影 or dp(2)))% e) x9 U: G; R' y/ _! b3 A
- path2.addRoundRect(rectf,外圆角 or dp(5),外圆角 or dp(5),Path.Direction.CW)4 m% T0 |9 X: [7 r
- path2.op(path1,Path.Op.DIFFERENCE)
L2 b A6 N8 P7 O8 Z: C P, U/ s - 画布.drawPath(path2,画笔)
1 C) Z% [ `! q) K - path1.reset()
6 {+ Q6 B G5 L" b, x - path2.reset()
3 g* `4 K2 P8 O. I3 Y7 v v - end)
1 c" U! `8 k4 X0 ]% d5 D - 画布.paint' e# K( L9 a1 ?7 J
- .setStrokeCap(Cap.ROUND)& {" Z: T2 J' b7 n. j$ P: d; x
- .setAntiAlias(true)
- i E- X- H c& A/ S - .setDither(true)' O4 R# X) L1 Z9 h
- .setShadowLayer(阴影 or dp(2),0,0,阴影颜色 or 0x7f000000); x# E1 x# Y. L1 Q. E! m* Q0 S& L
- .setColor(颜色 or 0xfff5f5f5)& O) P; b6 L: u: [; L4 T8 j w! Q
- view.background=画布
K( L2 v5 |$ k0 u7 a) s4 M( T - end
8 S% s* o2 x$ g* n8 m* J - 边框(相框)
: L( e' B/ m; f! T1 m- w. A
复制代码 |
|