flutter Container容器實現(xiàn)圓角邊框
本文實例為大家分享了flutter Container容器實現(xiàn)圓角邊框的具體代碼,供大家參考,具體內(nèi)容如下
在這里使用 Container 容器來實現(xiàn)圓角矩形邊框效果
1 圓角矩形邊框

Container(
margin: EdgeInsets.only(left: 40, top: 40),
//設(shè)置 child 居中
alignment: Alignment(0, 0),
height: 50,
width: 300,
//邊框設(shè)置
decoration: new BoxDecoration(
//背景
color: Colors.white,
//設(shè)置四周圓角 角度
borderRadius: BorderRadius.all(Radius.circular(4.0)),
//設(shè)置四周邊框
border: new Border.all(width: 1, color: Colors.red),
),
child: Text("Container 的圓角邊框"),
),
2 圓角矩形邊框

Container(
margin: EdgeInsets.only(left: 40, top: 40),
//設(shè)置 child 居中
alignment: Alignment(0, 0),
height: 50,
width: 300,
//邊框設(shè)置
decoration: new BoxDecoration(
//背景
color: Colors.white,
//設(shè)置四周圓角 角度 這里的角度應(yīng)該為 父Container height 的一半
borderRadius: BorderRadius.all(Radius.circular(25.0)),
//設(shè)置四周邊框
border: new Border.all(width: 1, color: Colors.red),
),
child: Text("Container 的圓角邊框"),
),
3 可點擊的圓角矩形邊框

使用 InkWell 來實現(xiàn) ,更多關(guān)于 InkWell 可查看 flutter InkWell 設(shè)置水波紋點擊效果詳述
Container(
margin: EdgeInsets.only(left: 40, top: 40),
child: new Material(
//INK可以實現(xiàn)裝飾容器
child: new Ink(
//用ink圓角矩形
// color: Colors.red,
decoration: new BoxDecoration(
//背景
color: Colors.white,
//設(shè)置四周圓角 角度
borderRadius: BorderRadius.all(Radius.circular(25.0)),
//設(shè)置四周邊框
border: new Border.all(width: 1, color: Colors.red),
),
child: new InkWell(
//圓角設(shè)置,給水波紋也設(shè)置同樣的圓角
//如果這里不設(shè)置就會出現(xiàn)矩形的水波紋效果
borderRadius: new BorderRadius.circular(25.0),
//設(shè)置點擊事件回調(diào)
onTap: () {},
child: Container(
//設(shè)置 child 居中
alignment: Alignment(0, 0),
height: 50,
width: 300,
child: Text("點擊 Container 圓角邊框"),
)),
),
),
),
4 可點擊的圓角矩形邊框

Container(
margin: EdgeInsets.only(left: 40, top: 40),
child: new Material(
child: new Ink(
//設(shè)置背景
decoration: new BoxDecoration(
//背景
color: Colors.white,
//設(shè)置四周圓角 角度
borderRadius: BorderRadius.all(Radius.circular(25.0)),
//設(shè)置四周邊框
border: new Border.all(width: 1, color: Colors.red),
),
child: new InkResponse(
borderRadius: new BorderRadius.all(new Radius.circular(25.0)),
//點擊或者toch控件高亮?xí)r顯示的控件在控件上層,水波紋下層
// highlightColor: Colors.deepPurple,
//點擊或者toch控件高亮的shape形狀
highlightShape: BoxShape.rectangle,
//.InkResponse內(nèi)部的radius這個需要注意的是,我們需要半徑大于控件的寬,如果radius過小,顯示的水波紋就是一個很小的圓,
//水波紋的半徑
radius: 300.0,
//水波紋的顏色
splashColor: Colors.yellow,
//true表示要剪裁水波紋響應(yīng)的界面 false不剪裁 如果控件是圓角不剪裁的話水波紋是矩形
containedInkWell: true,
//點擊事件
onTap: () {
print("click");
},
child: Container(
//設(shè)置 child 居中
alignment: Alignment(0, 0),
height: 50,
width: 300,
child: Text("點擊 Container 圓角邊框"),
),
),
),
),
),
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
android實現(xiàn)藍(lán)牙文件發(fā)送的實例代碼,支持多種機型
這篇文章主要介紹了android實現(xiàn)藍(lán)牙文件發(fā)送的實例代碼,有需要的朋友可以參考一下2014-01-01
Android開發(fā)實現(xiàn)簡單的觀察者與被觀察者示例
這篇文章主要介紹了Android開發(fā)實現(xiàn)簡單的觀察者與被觀察者,簡單描述了觀察者模式的概念、原理并結(jié)合實例形式分析了Android實現(xiàn)觀察者模式的簡單操作技巧,需要的朋友可以參考下2017-11-11
詳解Android開發(fā)錄音和播放音頻的步驟(動態(tài)獲取權(quán)限)
這篇文章主要介紹了詳解Android開發(fā)錄音和播放音頻的步驟(動態(tài)獲取權(quán)限),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-08-08
Android集成GreenDao數(shù)據(jù)庫的操作步驟
這篇文章主要介紹了Android集成GreenDao數(shù)據(jù)庫,使用數(shù)據(jù)庫存儲時候,一般都會使用一些第三方ORM框架,比如GreenDao,本文分幾步給大家介紹Android集成GreenDao數(shù)據(jù)庫的方法,需要的朋友可以參考下2022-10-10
Android判斷網(wǎng)絡(luò)類型的方法(2g,3g還是wifi)
這篇文章主要介紹了Android判斷網(wǎng)絡(luò)類型的方法,可實現(xiàn)判斷2g,3g還是wifi的功能,結(jié)合實例形式分析了Android針對網(wǎng)絡(luò)類型的相關(guān)判定技巧,需要的朋友可以參考下2016-02-02
Flutter?Ping檢查服務(wù)器通訊信號強度實現(xiàn)步驟
這篇文章主要為大家介紹了Flutter?Ping檢查服務(wù)器通訊信號強度實現(xiàn)步驟詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-06-06
Android手冊之Toolbar搜索聯(lián)動及監(jiān)聽小技巧
這篇文章主要為大家介紹了Android手冊之Toolbar搜索聯(lián)動及監(jiān)聽小技巧示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-09-09

