lua函数分享002,CYQ1。

6 寒雪落花静云月 2天前 108次点击

require("import")

import("android.app.*")

import("android.view.*")

import("android.webkit.MimeTypeMap")

import("android.widget.*")

import("java.io.File")

import("java.io.FileOutputStream")

import("android.os.Environment")

import("android.os.Build")

import("android.graphics.drawable.GradientDrawable")

function 导航栏颜色(颜色)

if Build.VERSION.SDK_INT>=21 then

activity.getWindow().setNavigationBarColor(颜色)

end

end

function 通知栏颜色(颜色)

if Build.VERSION.SDK_INT>=21 then

activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS).setStatusBarColor(颜色)

end

end

function 状态栏颜色(颜色)

if Build.VERSION.SDK_INT>=21 then

activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS).setStatusBarColor(颜色)

end

end

function 沉浸状态栏()

if Build.VERSION.SDK_INT>=19 then

activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)

end

end

function 获取状态栏高度()

if Build.VERSION.SDK_INT>=19 then

resourceId=activity.getResources().getIdentifier("status_bar_height","dimen","android")

return activity.getResources().getDimensionPixelSize(resourceId)

else

return 0

end

end

function 写入文件(路径, 内容)

f=File(tostring(File(tostring(路径)).getParentFile()).mkdirs())

io.open(tostring(路径),"w"):write(tostring(内容)):close()

end

function 读取文件(路径)

return io.open(路径):read("*a")

end

function lua内置提示(提示内容,背景颜色,文字颜色,卡片阴影)

toasts=

{

CardView,

id="toastb",

CardElevation=卡片阴影,

radius="1dp",

layout_width="fill",

background=背景颜色,

{

TextView,

layout_marginTop="12dp",

layout_marginBottom="12dp",

textSize="13sp",

TextColor=文字颜色,

layout_gravity="center",

text="Hello Ori",

id="mess"

}

}

message=tostring(提示内容)

Toast.makeText(activity,"内容",Toast.LENGTH_SHORT).setGravity(Gravity.BOTTOM | Gravity.FILL_HORIZONTAL,0,0)

Toast.makeText(activity,"内容",Toast.LENGTH_SHORT).setView(loadlayout(toasts))

mess.Text=message

Toast.makeText(activity,"内容",Toast.LENGTH_SHORT).show()

end

function 两角圆弧(目标视图,填充颜色,圆角半径)

drawable=GradientDrawable()

drawable.setColor(填充颜色)

drawable.setCornerRadii({圆角半径,圆角半径,圆角半径,圆角半径,0,0,0,0})

目标视图.setBackgroundDrawable(drawable)

end

内部储存地址=Environment.getExternalStorageDirectory().toString()

function 顶栏类颜色(路径)

if 读取文件(内部储存地址..路径)=="false" then

return "#ff5d6eff"

elseif 读取文件(内部储存地址..路径)=="true" then

return "#ff000000"

end

end

function 弹窗主文本颜色(路径)

if 读取文件(内部储存地址..路径)=="false" then

return "#ff000000"

elseif 读取文件(内部储存地址..路径)=="true" then

return "#ffffffff"

end

end

function 自适应顶部距离()

if Build.VERSION.SDK_INT==19 then

状态栏=获取状态栏高度()/2

顶距=状态栏.."dp"

return 顶距

elseif Build.VERSION.SDK_INT>19 then

状态栏=获取状态栏高度()/2

顶距=状态栏.."dp"

return 顶距

elseif Build.VERSION.SDK_INT<19 then

return "25dp"

end

end

共 3 条评论
0 

别分享了吧,差不多这种没人看。仅代表个人观点。

pskkalosqk 2天前
0 

别分享了吧,这种老掉牙的东西没人看。

0 

我表示看不懂

添加一条新评论

登录后可以发表评论 去登录