-- 状态栏沉浸透明
import "android.graphics.Color"
local window=this.getWindow()
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE)
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.setStatusBarColor(Color.TRANSPARENT)
状态栏高度=this.getResources().getDimensionPixelSize(luajava.bindClass("com.android.internal.R$dimen")().status_bar_height)
-- 按行取值(过滤空白行)
function 按行取值(内容,行数)
local s = 0
for a in 内容:gmatch("(.-)\n") do
if #a > 0 then
s = s + 1
if s == tonumber(行数) then return a end
end
end
local last = 内容:match("([^\n]+)$")
if last and #last > 0 then
s = s + 1
if s == tonumber(行数) then return last end
end
end
-- 获取远程数据并赋值
url="http://jishiben.site/?s=123123/k5ml4oOg:text"--网页链接
Http.get(url, nil, "UTF-8", nil, function(状态码, 远程内容)
-- 按行提取
local 我是标题 = 按行取值(远程内容,1)
标题.setText(我是标题)
local 第一行 = 按行取值(远程内容,2)
第一行文本.setText(第一行)
local 第二行 = 按行取值(远程内容,3)
第二行文本.setText(第二行)
local 第三行 = 按行取值(远程内容,5)
第三行文本.setText(第三行)
local 我是图片 = 按行取值(远程内容,4)
图片.setImageBitmap(loadbitmap(我是图片))
--没有获取数据时
local 赞美 = 按行取值(远程内容,6)
赞美美女.setText(赞美 or "当获取内容失败就会显示我,这个美女真好看")
--[[也可以这样写,省事,但是记忆不好还是重新写变量吧!
标题.setText(按行取值(远程内容,1))
]]
end)
-- 文本控件
function 文本(内容,id)
return {
TextView;
id=id;
text=内容;
textSize="17.5sp";
textColor="#222222";
}
end
-- 标题栏布局
标题栏布局={
LinearLayout;
orientation="horizontal";
layout_width="fill";
layout_height="56dp";
layout_marginTop=状态栏高度;
gravity="left|center";
{
TextView;
id="标题";
layout_marginLeft="4%w";
layout_weight="1";
textSize="18sp";
textColor="#ffffff";
singleLine=true;
},
{
ImageView;
layout_width="56dp";
layout_height="56dp";
padding="16dp";
src="icon.png";
},
}
-- 主布局
layout={
LinearLayout;
orientation="vertical";
layout_width="fill";
layout_height="fill";
{
LinearLayout;
orientation="vertical";
layout_width="fill";
layout_height="wrap";
background="#ff2196f3";
elevation="4dp";
标题栏布局,
};
{
ScrollView;
layout_width="fill";
layout_height="fill";
overScrollMode=View.OVER_SCROLL_NEVER;
verticalScrollBarEnabled=false;
{
LinearLayout;
orientation="vertical";
layout_width="fill";
layout_height="fill";
--开始布局
--文本
文本(nil,"第一行文本"),
文本(nil,"第二行文本"),
文本(nil,"第三行文本"),
--图片
{
ImageView;
id="图片";
layout_width="wrap";
layout_height="wrap";
},
文本(nil,"赞美美女"),
};
};
}
activity.setContentView(loadlayout(layout))--全屏布局
资源密码:yghy
本站资源,均来自网络,版权归原作者,所有资源和文章仅限用于学习和研究目的。
不得用于商业或非法用途,否则,一切责任由该用户承担!
您必须在下载后的24个小时之内,从您的电脑&手机中彻底删除下载的资源
资源失效,举报投诉,建议意见等,都可以来反馈。综合反馈