日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Unity_UIWidgets学习笔记03_组件_Container

發(fā)布時(shí)間:2025/4/16 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Unity_UIWidgets学习笔记03_组件_Container 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1、源碼

public Container(Key key = null,//唯一標(biāo)識符Alignment alignment = null,//子元素的排列方式EdgeInsets padding = null,//內(nèi)邊距Color color = null,//顏色,Decoration decoration = null,//繪制在child后面的裝飾,設(shè)置了decoration的話,就不能設(shè)置color屬性,否則會報(bào)錯(cuò),此時(shí)應(yīng)該在decoration中進(jìn)行顏色的設(shè)置。Decoration forgroundDecoration = null,//繪制在child前面的裝飾。float? width = null,//container的寬度float? height = null,//container的高度BoxConstraints constraints = null,//添加到child上額外的約束條件EdgeInsets margin = null,//外邊距Matrix3 transfrom = null,//變換矩陣Widget child = null//子元素)

2、例子

new Container(constraints:BoxConstraints.expand(height:Theme.of(context).textTheme.display1.fontSize*1.1f+200f),decoration:new BoxDecoration(border: Border.all(width: 2.0f, color: Colors.red),color: Colors.grey,borderRadius: BorderRadius.all(Radius.circular(20.0f)),image:new DecorationImage(image:new NetworkImage(@"https://hbimg.huabanimg.com/437658f08a68e1d24ea512b48b4a8cb7d808f3de25148-uBjU7Q_fw658"),centerSlice: Unity.UIWidgets.ui.Rect.fromLTRB(270.0f, 180.0f, 1360.0f, 730.0f))),alignment:Alignment.center,padding:EdgeInsets.all(8),margin:EdgeInsets.all(10f),// color:Colors.green,child:new Text("Hello World",style:Theme.of(context).textTheme.display1.copyWith(color:Colors.black)),transfrom:Matrix3.makeRotate(0.3f));

3,簡單使用

按鈕的狀態(tài)(正常態(tài)、點(diǎn)擊態(tài))的顏色變化;

new GestureDetector(child:new Container(constraints:BoxConstraints.expand(height:Theme.of(context).textTheme.display1.fontSize*1.1f+200f),decoration:new BoxDecoration(border: Border.all(width: 2.0f, color: Colors.red),color: btnColor,borderRadius: BorderRadius.all(Radius.circular(80.0f))),alignment:Alignment.center,padding:EdgeInsets.all(20),margin:EdgeInsets.only(top:350),// color:Colors.green,child:new Text("按鈕",style:Theme.of(context).textTheme.display1.copyWith(color:Colors.black))),onTapDown:(x)=>{setState(()=>{btnColor=Colors.blue;});},onTapUp:(x)=>{setState(()=>{btnColor=Colors.grey;});});

?

轉(zhuǎn)載于:https://www.cnblogs.com/PandaHome/p/11108439.html

總結(jié)

以上是生活随笔為你收集整理的Unity_UIWidgets学习笔记03_组件_Container的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。