|
- activity.setContentView(loadlayout{
( z% d! K: V: h T! Q - LinearLayout;, @2 n& O3 j0 t+ _# Y4 J( J
- gravity="center";
+ u. L2 f" l& ]/ T6 G - orientation="vertical";) d4 g3 v3 |' L- `- w( U9 J
- layout_width="fill";% T1 V2 x. j% W+ b7 y
- layout_height="fill";! U/ m$ U- _! p |, b
- {
/ ]( V$ k: N; r/ x2 b5 W - FrameLayout; k- p3 m& A) J* r
- layout_height=1080*0.35;
. ^* I# X8 t" E/ z& }/ p. z# U. W9 I - layout_width=1920*0.35;
3 G+ } [8 U: }! u" r% ~/ }5 l8 z - {! g W: {1 A" b4 V6 P
- ImageView;
9 U" N# D' G3 D$ \8 Z6 M - layout_height="fill";5 S4 _% K1 c, k) E3 A) p* T
- layout_width="fill";6 n$ W( f# E7 D b- n
- src="https://api.vvhan.com/api/bing";7 k6 w) w, s! w0 l. `3 t% Y( n5 j
- layout_margin="5dp";3 ?3 o8 j% _0 Y! j
- };( @$ t6 c/ N ] }. E) m$ D
- {% c5 h0 ]4 A V7 i8 }$ z* S9 l S1 L3 T
- LinearLayout;
7 _' l4 w, s- v0 m/ i - id="相框";9 N7 M& f: o1 y$ G
- layout_height=1080*0.35;' ?! d) g. ~ E
- layout_width=1920*0.35;
# U( X( v3 n- E# `5 ?; P+ H/ K - };1 `! {; @1 i5 x& G& s
- };7 a1 X1 e- W- a) \* g) i
- })
! }* Q) O6 s1 |) i( o) G, r( H3 S0 A
! d5 ^: [7 g3 w0 @( I- 0 f' d; N3 N( ~4 L$ M9 x! x2 l
- 1 G$ ~" p1 {5 U/ r% X# R( ^: c
- function 边框(view,宽度,阴影,颜色,阴影颜色,外圆角,内圆角)- U5 K& U0 Y7 G1 D, J5 [
- import "android.graphics.*"- k+ d% S- q8 M* v; B
- import "android.graphics.Paint$Cap"
6 ]! C2 q# ]3 W5 z* g - local scale = activity.getResources().getDisplayMetrics().scaledDensity
5 I6 [) ^) R8 D: z$ q# _5 s" F - function dp(dpValue)
* a% t( J: ?+ A3 |1 H - return dpValue * scale + 0.5
4 q* _3 z* P2 y7 \: o. K - end
7 P# R( y# L( e L# S0 o% | F" L - $rectf=RectF()
; {6 k r4 W5 _# g4 j+ Y( z - $path1=Path()
4 {3 V; \- s, r% j2 e* Z& J# k - $path2=Path()
! ^) e9 N5 s: ` - $画布=LuaDrawable(function(画布,画笔)
$ P) ^$ r: u3 J5 X; i! A- a; Z - 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))))
' w" h+ H0 E, L, u F& n ^# U8 x( p - path1.addRoundRect(rectf,内圆角 or dp(2.5),内圆角 or dp(2.5),Path.Direction.CW)6 I0 y6 T! N- @
- rectf.set((阴影 or dp(2)),(阴影 or dp(2)),画布.width-(阴影 or dp(2)),画布.height-(阴影 or dp(2)))
- K% b3 k2 C9 P* z7 T9 | - path2.addRoundRect(rectf,外圆角 or dp(5),外圆角 or dp(5),Path.Direction.CW)1 ]# k9 b3 e% f: I+ M" n9 @
- path2.op(path1,Path.Op.DIFFERENCE)# d8 X% M# Z8 F) W$ d$ N8 ]. B/ d
- 画布.drawPath(path2,画笔)) y4 ^( D( n) _4 v8 B
- path1.reset()# j3 F, ?# H; o8 G
- path2.reset()
% B- N& S _7 N' m; F1 | - end)
+ I; Z5 A2 i; ]) |% ] - 画布.paint
& W) t0 R% Q9 P- K$ G - .setStrokeCap(Cap.ROUND)
5 q W5 B% Q- A! I. M0 f - .setAntiAlias(true)0 }. H, w5 ~7 e" @' u4 h; f4 H
- .setDither(true)3 {5 z( @5 h$ N$ _$ H+ a) Q6 \- f8 P; I
- .setShadowLayer(阴影 or dp(2),0,0,阴影颜色 or 0x7f000000)) Z" R: J: e/ Z' S: c
- .setColor(颜色 or 0xfff5f5f5)3 W0 M) h5 j( O$ J. ]
- view.background=画布, B' Q& S6 F: k
- end, _, a+ X# L* e/ {, A
- 边框(相框)8 I) k. O% n% v* D/ c6 ?
复制代码 |
|