wangy 发表于 2021-7-1 08:25:09

【lua教程】音乐馆布局源码

   
--[[
阙歌制作
]]
require "import"
--导入布局所需资源
import "android.app.*"
import "android.os.*"
import "android.widget.*"
import "android.view.*"


--常用颜色(可自改)
tco1=0xFF000000
tco2=0xFF333333
tco3=0xFF7F7F7F
lco1="#FFFFFFFF"
lco2="#FFFAFAFA"
cco1=0xFFFFFFFF
cco2=0xFFEEEEEE
cco3=0xFFCCCCCC
cco4=0xFFF7F7F7
ico1=0xFF333333


--主页布局开始
Ti={
CardView;
CardElevation='15dp';
layout_width='fill';
layout_height='fill';
radius='0';
CardBackgroundColor=cco1;
id="hc2";
{
ListView;
layout_width="0",
layout_height="0",
id="lv";
};
{
LinearLayout;
Orientation='vertical';
layout_width='fill';
layout_height='fill';
background="#00ffffff",
{
LinearLayout;
Orientation='horizontal';
layout_width='fill';
layout_height='wrap';
padding="6%w";
{
TextView;
layout_weight='1';
layout_height='wrap';
Gravity='left|center';
textColor=tco1;
text='音乐馆';
textSize='30sp';
id="ht8";
};
{
TextView;
layout_width='wrap';
layout_height='fill';
Gravity='center';
textColor=tco1;
text='00:00 AM';
textSize='24sp';
id="ht9";
};
};
{
CardView;
layout_marginLeft='6%w';
layout_marginBottom='2%w';
CardElevation='0';
layout_width='88%w';
layout_height='45dp';
radius='15dp';
CardBackgroundColor=cco2;
id="hc3";
};
{
ScrollView;
layout_width='fill';
layout_height='fill';
VerticalScrollBarEnabled=false;
id='hs1';
{
LinearLayout;
Orientation='vertical';
layout_width='fill';
layout_height='fill';
{
LinearLayout;
Orientation='horizontal';
layout_width='fill';
layout_height='wrap';
{
TextView;
layout_weight='1';
layout_height='wrap';
layout_margin="6%w";
Gravity='left';
textColor=tco1;
text='个性电台';
textSize='14sp';
id="ht10";
};
{
TextView;
layout_width='wrap';
layout_height='wrap';
layout_margin="6%w";
Gravity='left';
textColor=tco2;
text='VIEW ALL';
id="ht28";
textSize='14sp';
};
};
{
LinearLayout;
Orientation='horizontal';
layout_width='fill';
layout_height='wrap';
paddingLeft='6%w';
{
CardView;
layout_gravity='left|center';
layout_marginLeft='0%w';
CardElevation='0';
layout_width='40%w';
radius='15dp';
layout_height='40%w';
CardBackgroundColor='#FF000000';
id="hc4";
{
ImageView;
id='hi1';
layout_width='fill';
layout_height='fill';
src="http://shp.qpic.cn/collector/3518828445/b4653db3-57d4-4f97-93e2-a1a5d9871e50/0";
};
};
{
LinearLayout;
Orientation='vertical';
layout_width='fill';
layout_height='fill';
{
CardView;
layout_gravity='left|center';
layout_marginLeft='2%w';
CardElevation='0';
layout_width='46%w';
radius='15dp';
layout_height='19%w';
CardBackgroundColor=cco2;
id="hc5";
{
LinearLayout;
Orientation='horizontal';
layout_width='fill';
layout_height='fill';
{
LinearLayout;
Orientation='vertical';
layout_weight='1';
layout_height='fill';
paddingLeft='5dp';
{
TextView;
id="ht11";
layout_width='fill';
layout_weight='1';
gravity='bottom|left';
textColor=tco1;
text="国风纯音";
textSize='14sp';
};
{
TextView;
id="ht12";
layout_width='fill';
layout_weight='1';
gravity='top|left';
textColor=tco3;
text="抚琴轻吟三两阕";
textSize='10sp';
};
};
{
CardView;
CardElevation='0';
layout_width='19%w';
radius='15dp';
layout_height='19%w';
CardBackgroundColor=cco4;
{
ImageView;
id='hi2';
src='http://shp.qpic.cn/collector/3518828445/88fa2a2d-52fc-44e4-851a-908763a2ba3b/0';
layout_width='fill';
layout_height='fill';
};
};
};
};
{
CardView;
layout_gravity='left|center';
layout_marginLeft='2%w';
layout_marginTop='2%w';
CardElevation='0';
layout_width='46%w';
radius='15dp';
layout_height='19%w';
CardBackgroundColor=cco2;
id="hc6";
{
LinearLayout;
Orientation='horizontal';
layout_width='fill';
layout_height='fill';
{
LinearLayout;
Orientation='vertical';
layout_weight='1';
layout_height='fill';
paddingLeft='5dp';
{
TextView;
id="ht13";
layout_width='fill';
layout_weight='1';
gravity='bottom|left';
textColor=tco1;
text="思念无期";
textSize='14sp';
};
{
TextView;
id="ht14";
layout_width='fill';
layout_weight='1';
gravity='top|left';
textColor=tco3;
text="难以忘却你的好";
textSize='10sp';
};
};
{
CardView;
CardElevation='0';
layout_width='19%w';
radius='15dp';
layout_height='19%w';
CardBackgroundColor=cco4;
id="hc7";
{
ImageView;
id='hi3';
src="http://shp.qpic.cn/collector/3518828445/7fd830ad-d209-43ee-b9e0-64df68a34d98/0";
layout_width='fill';
layout_height='fill';
};
};
};
};
};
};
{
LinearLayout;
layout_marginTop='6%w';
layout_gravity="center";
layout_width='88%w';
layout_height='2dp';
background=lco2;
};
{
LinearLayout;
Orientation='horizontal';
layout_width='fill';
layout_height='wrap';
{
TextView;
layout_weight='1';
layout_height='wrap';
layout_margin="6%w";
Gravity='left';
textColor=tco1;
text='热门推荐';
textSize='14sp';
id="ht15";
};
{
TextView;
layout_width='wrap';
layout_height='wrap';
layout_margin="6%w";
Gravity='left';
textColor=tco2;
text='VIEW ALL';
id="ht29";
textSize='14sp';
};
};
{
LinearLayout;
Orientation='horizontal';
layout_width='fill';
layout_height='wrap';
paddingLeft='4.5%w';
paddingRight='4.5%w';
{
LinearLayout;
Orientation='vertical';
layout_weight='1';
layout_height='wrap';
{
CardView;
CardElevation='0';
layout_width='15.6%w';
radius='15dp';
layout_height='15.6%w';
CardBackgroundColor=cco2;
layout_gravity='center';
id="hc8";
{
CardView;
CardElevation='0';
layout_width='13.6%w';
radius='12dp';
layout_height='13.6%w';
CardBackgroundColor='#FF000000';
layout_margin='1%w';
layout_gravity='center';
{
ImageView;
src='http://shp.qpic.cn/collector/3518828445/71bfe03f-9b77-492b-82ef-43c2d07dc619/0';
layout_width='fill';
layout_height='fill';
};
};
};
{
TextView;
layout_width='fill';
layout_height='wrap';
Gravity='center';
textColor=tco2;
text='翻译';
textSize='14sp';
id="ht16";
};
};
{
LinearLayout;
Orientation='vertical';
layout_weight='1';
layout_height='wrap';
{
CardView;
CardElevation='0';
layout_width='15.6%w';
radius='15dp';
layout_height='15.6%w';
CardBackgroundColor=cco2;
layout_gravity='center';
id="hc9";
{
CardView;
CardElevation='0';
layout_width='13.6%w';
radius='12dp';
layout_height='13.6%w';
CardBackgroundColor="#FF000000";
layout_margin='1%w';
layout_gravity='center';
{
ImageView;
src='http://shp.qpic.cn/collector/3518828445/6716cf79-253f-430c-a0f1-1b3052cf481e/0';
layout_width='fill';
layout_height='fill';
};
};
};
{
TextView;
layout_width='fill';
layout_height='wrap';
Gravity='center';
textColor=tco2;
text='歌单';
textSize='14sp';
id="ht17";
};
};
{
LinearLayout;
Orientation='vertical';
layout_weight='1';
layout_height='wrap';
{
CardView;
CardElevation='0';
layout_width='15.6%w';
radius='15dp';
layout_height='15.6%w';
CardBackgroundColor=cco2;
layout_gravity='center';
id="hc10";
{
CardView;
CardElevation='0';
layout_width='13.6%w';
radius='12dp';
layout_height='13.6%w';
CardBackgroundColor='#FF000000';
layout_margin='1%w';
layout_gravity='center';
{
ImageView;
src='http://shp.qpic.cn/collector/3518828445/25caff36-a829-437a-8271-2cb0441aadcd/0';
layout_width='fill';
layout_height='fill';
};
};
};
{
TextView;
layout_width='fill';
layout_height='wrap';
Gravity='center';
textColor=tco2;
text='排行';
textSize='14sp';
id="ht18";
};
};
{
LinearLayout;
Orientation='vertical';
layout_weight='1';
layout_height='wrap';
{
CardView;
CardElevation='0';
layout_width='15.6%w';
radius='15dp';
layout_height='15.6%w';
CardBackgroundColor=cco2;
layout_gravity='center';
id="hc11";
{
CardView;
CardElevation='0';
layout_width='13.6%w';
radius='12dp';
layout_height='13.6%w';
CardBackgroundColor='#FF000000';
layout_margin='1%w';
layout_gravity='center';
{
ImageView;
src='http://shp.qpic.cn/collector/3518828445/b88f2768-9fd9-45c0-b784-3134d58d17c5/0';
layout_width='fill';
layout_height='fill';
};
};
};
{
TextView;
layout_width='fill';
layout_height='wrap';
Gravity='center';
textColor=tco2;
text='发现';
textSize='14sp';
id="ht19";
};
};
{
LinearLayout;
Orientation='vertical';
layout_weight='1';
layout_height='wrap';
{
CardView;
CardElevation='0';
layout_width='15.6%w';
radius='15dp';
layout_height='15.6%w';
CardBackgroundColor=cco2;
layout_gravity='center';
id="hc12";
{
CardView;
CardElevation='0';
layout_width='13.6%w';
radius='12dp';
layout_height='13.6%w';
CardBackgroundColor='#FF000000';
layout_margin='1%w';
layout_gravity='center';
{
ImageView;
src='http://shp.qpic.cn/collector/3518828445/49b5a047-0012-4178-bf8f-8c5555d9de67/0';
layout_width='fill';
layout_height='fill';
};
};
};
{
TextView;
layout_width='fill';
layout_height='wrap';
Gravity='center';
textColor=tco2;
text='一起听';
textSize='14sp';
id="ht20";
};
};
};
{
LinearLayout;
layout_marginTop='6%w';
layout_gravity="center";
layout_width='88%w';
layout_height='2dp';
background=lco2;
id="hc13";
};
{
LinearLayout;
Orientation='horizontal';
layout_width='fill';
layout_height='wrap';
{
TextView;
layout_weight='1';
layout_height='wrap';
layout_margin="6%w";
Gravity='left';
textColor=tco1;
text='音乐播放';
textSize='14sp';
id="ht21";
};
{
TextView;
layout_width='wrap';
layout_height='wrap';
layout_margin="6%w";
Gravity='left';
textColor=tco2;
text='VIEW ALL';
id="ht30";
textSize='14sp';
};
};
{
LinearLayout;
Orientation='horizontal';
layout_width='fill';
layout_height='wrap';
paddingLeft="3%w";
paddingRight="3%w";
{
LinearLayout;
Orientation='vertical';
layout_weight='1';
layout_height='wrap';
{
CardView;
layout_gravity='center';
CardElevation='10';
layout_width='27.3%w';
layout_height='150dp';
radius='15dp';
CardBackgroundColor='#ff000000';
id="hc14";
{
ImageView;
src='http://shp.qpic.cn/collector/3518828445/53c08217-2fb0-4019-af9e-394524dc43d9/0';
scaleType="fitXY";
layout_width='fill';
layout_height='fill';
};
{
CardView;
layout_gravity='bottom';
CardElevation='0';
layout_width='fill';
layout_height='45dp';
radius='13dp';
CardBackgroundColor=cco5;
id="hc15";
{
CardView;
layout_gravity='gravity';
CardElevation='0';
layout_width='fill';
layout_height='fill';
radius='12dp';
CardBackgroundColor=cco1;
{
TextView;
layout_width='fill';
layout_height='fill';
Gravity='center';
textColor=tco1;
text='本地音乐';
textSize='16sp';
id="ht23";
};
};
};
};
};
{
LinearLayout;
Orientation='vertical';
layout_weight='1';
layout_height='wrap';
{
CardView;
layout_gravity='center';
CardElevation='10';
layout_width='27.3%w';
layout_height='150dp';
radius='15dp';
CardBackgroundColor='#ff000000';
id="hc16";
{
ImageView;
src='http://shp.qpic.cn/collector/3518828445/46c7fe22-1975-427c-916c-f68b675979a8/0';
scaleType="fitXY";
layout_width='fill';
layout_height='fill';
};
{
CardView;
layout_gravity='bottom';
CardElevation='0';
layout_width='fill';
layout_height='45dp';
radius='13dp';
CardBackgroundColor=cco6;
id="hc17";
{
CardView;
layout_gravity='gravity';
CardElevation='0';
layout_width='fill';
layout_height='fill';
radius='12dp';
CardBackgroundColor=cco1;
id="hc18";
{
TextView;
layout_width='fill';
layout_height='fill';
Gravity='center';
textColor=tco1;
text='网络歌单';
textSize='16sp';
id="ht25";
};
};
};
};
};
{
LinearLayout;
Orientation='vertical';
layout_weight='1';
layout_height='wrap';
{
CardView;
layout_gravity='center';
CardElevation='10';
layout_width='27.3%w';
layout_height='150dp';
radius='15dp';
CardBackgroundColor='#ff000000';
id="hc19";
{
ImageView;
src='http://shp.qpic.cn/collector/3518828445/30fd6d02-3e2e-47a5-9b16-094ab5a74fbe/0';
scaleType="fitXY";
layout_width='fill';
layout_height='fill';
};
{
CardView;
layout_gravity='bottom';
CardElevation='0';
layout_width='fill';
layout_height='45dp';
radius='13dp';
CardBackgroundColor=cco7;
id="hc20";
{
CardView;
layout_gravity='gravity';
CardElevation='0';
layout_width='fill';
layout_height='fill';
radius='12dp';
CardBackgroundColor=cco1;
id="hc21";
{
TextView;
layout_width='fill';
layout_height='fill';
Gravity='center';
textColor=tco1;
text='在线音乐';
textSize='16sp';
id="ht27";
};
};
};
};
};
};
};
};
};
};


--设置布局视图
activity.setContentView(loadlayout(Ti))
页: [1]
查看完整版本: 【lua教程】音乐馆布局源码