主頁 > 移動端開發 > Flutter-UI-基礎控制元件

Flutter-UI-基礎控制元件

2021-08-13 07:51:27 移動端開發

一直覺得自己寫的不是技術,而是情懷,一個個的教程是自己這一路走來的痕跡,靠專業技能的成功是最具可復制性的,希望我的這條路能讓你們少走彎路,希望我能幫你們抹去知識的蒙塵,希望我能幫你們理清知識的脈絡,希望未來技術之巔上有你們也有我,

小知識

1.int _currentIndex = 0; 創建帶有下劃線屬性 是一個私有屬性

Center

作用:用于中心對齊文字
屬性
child

Center(
  child: ,
)

Text

child: Text(
    'fenghanxuqwertyuiopasdfgjkgh',
    overflow: TextOverflow.clip,//ellipsis 超出一行3個點   fade 超出一行漸變  clip 超出一行裁剪
    maxLines: 3,//設定Label的行數
    textScaleFactor: 2,//字體放大兩倍
    textAlign: TextAlign.center,//對齊方式
    textDirection: TextDirection.ltr,
    style: TextStyle(//設定文字樣式
        decoration: TextDecoration.lineThrough,//中間有一個行橫線
        decorationColor: Colors.white,//中間有一個行橫線 顏色
        decorationStyle: TextDecorationStyle.dashed,//中間有一個行橫線 虛線
        letterSpacing: 0.0,//字體之間的左右間距
        fontStyle: FontStyle.italic,//字體傾斜
        fontWeight: FontWeight.w900,//字體粗細(加粗)
        backgroundColor: Colors.red,//設定背景顏色
        fontSize: 20.0,//設定文字大小
        color: Color.fromRGBO(234, 123, 155, 1.0),//設定文字顏色
//          color: Colors.yellow,//設定文字顏色
   ),
),

MaterialApp

是一個跟組件 作為App的跟組件 相當于每個頁面都要加的 加了之后頁面默認是白色的,不然是黑色的

屬性
home - 主頁
title - 標題
color - 顏色
theme - 主題
routes - 路由

固定頁面結構
return MaterialApp(
  home: Scaffold(
    appBar: AppBar(
      title: Text('Flutter Demol'),
    ),
    body: HomeContent(),
  ),
  theme: ThemeData(
    primarySwatch: Colors.yellow,//修改主題顏色   想導航欄的顏色
  ),
);

Scaffold

屬性
appBar - 顯示假面頂部的一個AppBar
body - 當前界面所顯示的主要內容
drawer - 抽屜選單控制元件

Container

容器組件
屬性
child
height
width
decoration 設定背景顏色和邊框顏色

child: Container(
  child: Text('fenghanxuqwertyuiopasdfgjkgh'),
  height: 300,
  width: 300,
  decoration: BoxDecoration(
     color: Colors.blue,//容易背景顏色
     border: Border.all(
              color: Colors.green,//邊框顏色
              width: 2//邊框寬度
     ),
     borderRadius: BorderRadius.all(Radius.circular(10.0),),//設定容器圓角
  ),
//padding: EdgeInsets.all(20),//容器之間的內邊距
  padding: EdgeInsets.fromLTRB(20, 20, 20, 20),//容器之間的內邊距
//margin: EdgeInsets.all(20), //容器之間的外距離
  margin:  EdgeInsets.fromLTRB(20, 20, 20, 20),//容器之間的外距離
//transform: Matrix4.translationValues(10, 10, 10),//容器位移
//transform: Matrix4.rotationZ(0.3),//旋轉 Matrix4.rotationX(0.3), Matrix4.rotationY(0.3),
//transform: Matrix4.diagonal3Values(0.5, 0.5, 0.5),//縮放倍數
  alignment: Alignment.bottomRight,//內容相對容器的對齊方式
),

Image

網路圖片加載不成功兩個問題:
1.是否連接wifi
2.重新燒錄需要點擊是否同意訪問網路
3.url是否有效
加載網路圖片

child: Image.network(
  'https://www.itying.com/images/upload/Image/3333333.png',
  alignment: Alignment.bottomRight,//圖片相對容器的對齊方式
  color: Colors.yellow,//圖片背景顏色
  colorBlendMode: BlendMode.colorBurn,//圖片混合模式
  fit: BoxFit.cover,//顯示效果 cover  自適應 fill  鋪滿可能變形 fitWidth 寬充滿 filHright 高充滿 repeat 多張圖片平鋪
),

圖片切圓方法
加載網路圖片

child: Container(
  child: ClipOval(
    child: Image.asset('https://www.itying.com/images/flutter/2.png',
    width: 100,
    height: 100,
    fit: BoxFit.cover,),
  ),
),

匯入本地圖片
在這里插入圖片描述
在這里插入圖片描述

child: Container(
  child: ClipOval(
    child: Image.asset('images/NahuoLogo1024.png',
    width: 100,
    height: 100,
    fit: BoxFit.cover,),
  ),
),

ListView 串列

在這里插入圖片描述

最簡單的串列

    return ListView(
//      scrollDirection: Axis.horizontal,//設定水平串列
      padding: EdgeInsets.all(10),//設定上下左右間距20
      children: <Widget>[
        ListTile(
          leading: Icon(Icons.home,color: Colors.blue,size: 40,),//加載系統圖示
          title: Text(
            'fenghanxu',
            style: TextStyle(
              fontSize: 20,
            ),
          ),
          subtitle: Text('subtitleFenghanxu'),
          trailing: Icon(Icons.search,color: Colors.blue,size: 40,),
        ),
        ListTile(
          leading: Image.network('https://www.itying.com/images/flutter/1.png'),//加載網路圖片
          title: Text('fenghanxu'),
          subtitle: Text('subtitleFenghanxu'),
        ),
      ],
    );

通過for回圈實作動態遍歷ListItem串列
在這里插入圖片描述

class _MyHomePageState extends State<MyHomePage> {

  List<Widget> _getData(){
    List<Widget> list = new List();
    for(var i = 0; i < 20; i++){
      list.add(ListTile(
        title: Text('i am is $i list'),
      ));
    }
    return list;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: ListView(
//      scrollDirection: Axis.horizontal,//設定水平串列
          padding: EdgeInsets.all(10),//設定上下左右間距20
          children: _getData(),
        ),
      ),
    );
  }
}

GridView 網格

GridView.count 靜態網格布局

//GridView  for回圈資料
import 'package:flutter/material.dart';
import 'res/listData.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('Flutter Demol'),),
        body: HomeContent(),
      ),
    );
  }

}


class HomeContent extends StatelessWidget {

  List<Widget> _getListData(){
    var tempList = listData.map((value){
      return Container(
        child: Column(
          children: <Widget>[
            Image.network(value['imageUrl']),
            SizedBox(
              height: 20,//圖片跟文字的間距是20
            ),
            Text(
              value['title'],
              textAlign: TextAlign.center,
              style: TextStyle(
                  fontSize: 15
              ),
            )
          ],
        ),
        decoration: BoxDecoration(//添加邊框
            border: Border.all(
                color: Color.fromRGBO(233, 233, 233, 0.9),
                width: 1.0
            )
        ),
      );
    });
    return tempList.toList();
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return GridView.count(
      crossAxisSpacing: 20.0,//設定cell的左右間距為20
      mainAxisSpacing: 20.0,//設定cell的上下間距為20
      padding: EdgeInsets.all(10),//設定cell的內間距為10(上下左右)
      crossAxisCount: 2,//控制列數
      childAspectRatio: 0.9,//只能調節X Y軸的比例  寬高比0.7
      children: this._getListData(),
    );

  }

}

GridView.builder 動態網格布局

//GridView  資料   GridView.count 靜態網格布局
import 'package:flutter/material.dart';
import 'res/listData.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('Flutter Demol'),),
        body: HomeContent(),
      ),
    );
  }

}


class HomeContent extends StatelessWidget {

  Widget _getListData(context,index){
    return Container(
      child: Column(
        children: <Widget>[
          Image.network(listData[index]['imageUrl']),
          SizedBox(
            height: 20,//圖片跟文字的間距是20
          ),
          Text(
            listData[index]['title'],
            textAlign: TextAlign.center,
            style: TextStyle(
                fontSize: 20
            ),
          )
        ],
      ),
      decoration: BoxDecoration(//添加邊框
          border: Border.all(
              color: Color.fromRGBO(233, 233, 233, 0.9),
              width: 1.0
          )
      ),
    );
//    return tempList.toList();
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return GridView.builder(
      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
        crossAxisSpacing: 10.0,//設定cell的左右間距為20
        mainAxisSpacing: 10.0,//設定cell的上下間距為20
        crossAxisCount: 2,
      ),
      itemCount: listData.length,//便利的次數是陣列的次數
      itemBuilder: this._getListData,//資料方法
    );

  }

}

BoxDecoration 邊框

BoxDecoration(
     color: Colors.blue,//容易背景顏色
     border: Border.all(
              color: Colors.green,//邊框顏色
              width: 2//邊框寬度
     ),
     borderRadius: BorderRadius.all(Radius.circular(10.0),),//設定容器圓角
  )

SizedBox 間隙

SizedBox( height: 20,)//圖片跟文字的間距是20

Padding 外邊框控制元件

return Padding(
  padding: EdgeInsets.fromLTRB(10, 10, 0, 0),
  child: Image.network(
      'https://www.itying.com/images/flutter/1.png', fit: BoxFit.cover),
);

Row 水平布局控制元件

return Row(
  //center start end  spaceAround 兩邊留固定空隙  spaceBetween 中間留空隙 spaceEvenly  兩邊留平均空隙
  mainAxisAlignment: MainAxisAlignment.start,//X軸的顯示方式
  //crossAxisAlignment: CrossAxisAlignment.end,//Y軸的顯示方式 要用一個參考物用的比較小
  children: <Widget>[
    IconContainer(Icons.search,color: Colors.blue,size: 30,),
    IconContainer(Icons.home,color: Colors.yellow,size: 30,),
    IconContainer(Icons.settings,color: Colors.green,size: 30,),
  ],
);

Column 垂直布局控制元件

return Container(
  width: 200,
  height: 400,
  color: Colors.pink,
  child: Column(
    //center start end  spaceAround 兩邊留固定空隙  spaceBetween 中間留空隙 spaceEvenly  兩邊留平均空隙
    mainAxisAlignment: MainAxisAlignment.spaceEvenly,//X軸的顯示方式
    //crossAxisAlignment: CrossAxisAlignment.end,//Y軸的顯示方式 要用一個參考物用的比較小
    children: <Widget>[
      IconContainer(Icons.search,color: Colors.blue,size: 30,),
      IconContainer(Icons.home,color: Colors.yellow,size: 30,),
      IconContainer(Icons.settings,color: Colors.orange,size: 30,),
    ],
  ),
);

Expanded 控制元件相對父View的寬度比例

return Container(
  width: 400,
  height: 100,
  color: Colors.pink,
  child: Row(
    //center start end  spaceAround 兩邊留固定空隙  spaceBetween 中間留空隙 spaceEvenly  兩邊留平均空隙
    mainAxisAlignment: MainAxisAlignment.spaceEvenly,//X軸的顯示方式
    //crossAxisAlignment: CrossAxisAlignment.end,//Y軸的顯示方式 要用一個參考物用的比較小
    children: <Widget>[
      Expanded(
        flex: 1,
        child: IconContainer(Icons.search,color: Colors.blue,size: 30,),
      ),
      Expanded(
        flex: 2,
        child: IconContainer(Icons.home,color: Colors.yellow,size: 30,),
      ),
    ],
  ),
); 

Stack

Stack配合Align 使用 Stack 它可以控制子組件的位置

return  Center(
  child: Container(
    height: 400.0,
    width: 300.0,
    color: Colors.red,
    child: Stack(
      alignment: Alignment.center,
      children: <Widget>[
        Align(
          alignment: Alignment.topLeft,
          child: Icon(Icons.home,size: 40,color: Colors.white),
        ),
        Align(
          alignment: Alignment.center,
          child: Icon(Icons.search,size: 40,color: Colors.white),
        ),
        Align(
          alignment: Alignment.bottomRight,
          child: Icon(Icons.select_all,size: 40,color: Colors.white),
        ),
        Align(
          alignment: Alignment(1.0,-0.2),
          child: Icon(Icons.security,size: 40,color: Colors.white),
        ),
      ],
    ),
  ),
);

Stack配合Positioned 使用 Stack 它可以控制子組件的位置

return  Center(
  child: Container(
    height: 400.0,
    width: 300.0,
    color: Colors.red,
    child: Stack(
      alignment: Alignment.center,
      children: <Widget>[
        Positioned(
          left: 10,
          child: Icon(Icons.home,size: 40,color: Colors.white),
        ),
        Positioned(
          bottom: 0,
          left: 100,
          child: Icon(Icons.search,size: 40,color: Colors.white),
        ),
        Positioned(
          right: 10,
          top: 10,
          child: Icon(Icons.select_all,size: 40,color: Colors.white),
        ),
        Positioned(
          bottom: 10,
          left: 10,
          child: Icon(Icons.security,size: 40,color: Colors.white),
        ),
      ],
    ),
  ),
);

AspectRatio 用于設定子控制元件是父控制元件的螢屏比例

AspectRatio的作用是調整child到設定的寬高比

return AspectRatio(
  aspectRatio: 2.0/1.0,
  child: Container(
    color: Colors.red,
  ),
);

Card 卡片組件 底部帶陰影組件

return Card(
  margin: EdgeInsets.all(10),
  child: Column(
    children: <Widget>[
      ListTile(
        title: Text('張三',style: TextStyle(fontSize: 28)),
        subtitle: Text('高級工程師'),
      ),
      ListTile(
        title: Text('電話:15989954385'),
      ),
      ListTile(
        title: Text('地址: 逢簡馮家大街'),
      )
    ],
  ),
);

RaisedButton 突出按鍵

return RaisedButton(
  child: Text(this.text),
  textColor: Theme.of(context).accentColor,
  onPressed: (){

  },
);

Wrap 相當于不等寬按鍵布局

    return Wrap(
      spacing: 20,//設定每個小容器之前的左右間距為20
      runSpacing: 10,//設定每個小容器之前的上下間距為10
//      alignment: WrapAlignment.spaceEvenly,//整個View的對齊方式  用的比較小
      runAlignment: WrapAlignment.end,
      direction: Axis.horizontal,//vertical  horizontal
      children: <Widget>[
        MyButton('第一季'),
        MyButton('第一季1'),
        MyButton('第一季12'),
        MyButton('第一季123'),
        MyButton('第一季1234'),
        MyButton('第一季4'),
        MyButton('第一季3'),
      ],
    );

StatefulWidget

狀態組件 因為它有一個setState方法
如果想改變頁面中的資料就用StatefulWidget

class HomeContent extends StatefulWidget {

  HomeContent({Key key}) : super(key: key);
  //建構式   固定寫法
  _HomeContentState createState() => _HomeContentState();

}

class _HomeContentState extends State<HomeContent> {

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return null;
  }

}

StatelessWidget

無狀態組件 不能改變控制元件里面的值

class HomeContent extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return null;
  }
}

BarNavigationView 底部導航欄

import 'package:flutter/material.dart';
import 'res/listData.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      home: Tabs(),
    );
  }
}


//StatefulWidget
class Tabs extends StatefulWidget {

  Tabs({Key key}) : super(key: key);

  _TabsState createState() => _TabsState();

}

class _TabsState extends State<Tabs> {

  int _currentIndex = 0;

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(title: Text('Flutter Demol'),),
      body: HomePage(),
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: this._currentIndex,
        onTap: (int index){
          setState(() {
            this._currentIndex = index;
          });
        },
        iconSize:36.0,//icon大小
        fixedColor:Color.red,//icon顏色
        type:BottomNavigationBarType.fixed,//設定tabbar可以有多個按鈕
        items: [
          BottomNavigationBarItem(
            icon: Icon(Icons.home),
            title: Text('首頁'),
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.category),
            title: Text('分類'),
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.settings),
            title: Text('設定'),
          ),
        ],
      ),
    );
  }

}

class HomePage extends StatelessWidget{

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Center(
      child: Text('fenghanxu'),
    );
  }

}

缺小:tabbar底部導航欄切換控制器Demol 30視頻,

route 路由

基本路由 不帶引數

return Container(
  child: Center(
    child: RaisedButton(
      child: Text('按鍵-搜索'),
      color: Theme.of(context).accentColor,
      textTheme: ButtonTextTheme.primary,
      onPressed: (){
       //路由
        Navigator.of(context).push(
            MaterialPageRoute(
                builder: (context)=>searchPage()
            )
        );
      },),
  ),
);

基本路由 帶引數

return Container(
  child: Center(
    child: RaisedButton(
      child: Text('按鍵-搜索'),
      color: Theme.of(context).accentColor,
      textTheme: ButtonTextTheme.primary,
      onPressed: (){
      //路由
        Navigator.of(context).push(
            MaterialPageRoute(
                builder: (context)=>searchPage(title: 'sendToTitle',)
            )
        );
      },),
  ),
);

回傳pop

Navigator.of(content).pop();

命名路由

搜索控制器代碼
在這里插入圖片描述
在這里插入圖片描述

路由代碼
在這里插入圖片描述
跳轉 不帶引數
在這里插入圖片描述

跳轉 帶引數
在這里插入圖片描述
路由替換
路由替換 用下一個控制器替換當前控制器 不斷替換回來根目錄 就是跳轉之后回傳的時候上一個控制器被銷毀了

Navigator.of(context).pushReplacementNamed('/login');

普通路由跳轉回根目錄

Navigator.of(context).pushAndRemoveUntil(
  new MaterialPageRoute(builder: (context) => new Tabs(index: 0,)),
    (route) => route == null
);

自定義AppBar 導航欄

在這里插入圖片描述

return Scaffold(
  appBar: AppBar(
    title: Text('Hello Flutter'),
    backgroundColor: Colors.red,
    centerTitle: true,//標題居中顯示
    leading: IconButton(
        icon: Icon(Icons.menu),
        onPressed: (){
          print('點擊左邊按鍵');
    }),
    actions: <Widget>[
      IconButton(
          icon: Icon(Icons.search),
          onPressed: (){
            print('點擊右邊按鍵1');
          }),
      IconButton(
          icon: Icon(Icons.settings),
          onPressed: (){
            print('點擊右邊按鍵2');
          }),
    ],
  ),
  body: Center(
    child: Container(
      child: Text('hello flutter'),
    ),
  ),
);

普通控制器頂部TabBar切換

在這里插入圖片描述

class _categoryPageState extends State<categoryPage> {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return DefaultTabController(
        length: 2,
        child: Scaffold(
          appBar: AppBar(
            title: Row(
              children: <Widget>[
                Expanded(
                    child: TabBar(
                        indicatorColor: Colors.white,//選中Label顏色
                        labelColor: Colors.white,//選中文字顏色
                        unselectedLabelColor: Colors.white,//未選中文字顏色
                        indicatorSize: TabBarIndicatorSize.label,//指示器長度
                        isScrollable: true,//如果多個按鈕的話可以滑動
                        tabs: <Widget>[
                           Tab(text: '軍事'),
                           Tab(text: '經濟'),
                    ]))
              ],
            ),
            centerTitle: true, //標題居中顯示
          ),
          body: TabBarView(children: <Widget>[
            ListView(
              children: <Widget>[
                ListTile(
                  title: Text('第一行'),
                ),
                ListTile(
                  title: Text('第二行'),
                ),
                ListTile(
                  title: Text('第三行'),
                ),
              ],
            ),
            ListView(
              children: <Widget>[
                ListTile(
                  title: Text('第一行'),
                ),
                ListTile(
                  title: Text('第二行'),
                ),
                ListTile(
                  title: Text('第三行'),
                ),
              ],
            )
          ]),
        ));
  }
}

Tabbar常用屬性
在這里插入圖片描述
視頻35(看3分之一) 有一個更好的tabbar切換方式 沒有寫原始碼

轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/293384.html

標籤:其他

上一篇:Calling a method in the system process without a qualified user

下一篇:Android免權限懸浮窗組件 - FloatingX

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 【從零開始擼一個App】Dagger2

    Dagger2是一個IOC框架,一般用于Android平臺,第一次接觸的朋友,一定會被搞得暈頭轉向。它延續了Java平臺Spring框架代碼碎片化,注解滿天飛的傳統。嘗試將各處代碼片段串聯起來,理清思緒,真不是件容易的事。更不用說還有各版本細微的差別。 與Spring不同的是,Spring是通過反射 ......

    uj5u.com 2020-09-10 06:57:59 more
  • Flutter Weekly Issue 66

    新聞 Flutter 季度調研結果分享 教程 Flutter+FaaS一體化任務編排的思考與設計 詳解Dart中如何通過注解生成代碼 GitHub 用對了嗎?Flutter 團隊分享如何管理大型開源專案 插件 flutter-bubble-tab-indicator A Flutter librar ......

    uj5u.com 2020-09-10 06:58:52 more
  • Proguard 常用規則

    介紹 Proguard 入口,如何查看輸出,如何使用 keep 設定入口以及使用實體,如何配置壓縮,混淆,校驗等規則。

    ......

    uj5u.com 2020-09-10 06:59:00 more
  • Android 開發技術周報 Issue#292

    新聞 Android即將獲得類AirDrop功能:可向附近設備快速分享檔案 谷歌為安卓檔案管理應用引入可安全隱藏資料的Safe Folder功能 Android TV新主界面將顯示電影、電視節目和應用推薦內容 泄露的Android檔案暗示了傳說中的谷歌Pixel 5a與折疊屏新機 谷歌發布Andro ......

    uj5u.com 2020-09-10 07:00:37 more
  • AutoFitTextureView Error inflating class

    報錯: Binary XML file line #0: Binary XML file line #0: Error inflating class xxx.AutoFitTextureView 解決: <com.example.testy2.AutoFitTextureView android: ......

    uj5u.com 2020-09-10 07:00:41 more
  • 根據Uri,Cursor沒有獲取到對應的屬性

    Android: 背景:呼叫攝像頭,拍攝視頻,指定保存的地址,但是回傳的Cursor檔案,只有名稱和大小的屬性,沒有其他諸如時長,連ID屬性都沒有 使用 cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DURATIO ......

    uj5u.com 2020-09-10 07:00:44 more
  • Android連載29-持久化技術

    一、持久化技術 我們平時所使用的APP產生的資料,在記憶體中都是瞬時的,會隨著斷電、關機等丟失資料,因此android系統采用了持久化技術,用于存盤這些“瞬時”資料 持久化技術包括:檔案存盤、SharedPreference存盤以及資料庫存盤,還有更復雜的SD卡記憶體儲。 二、檔案存盤 最基本存盤方式, ......

    uj5u.com 2020-09-10 07:00:47 more
  • Android Camera2Video整合到自己專案里

    背景: Android專案里呼叫攝像頭拍攝視頻,原本使用的 MediaStore.ACTION_VIDEO_CAPTURE, 后來因專案需要,改成了camera2 1.Camera2Video 官方demo有點問題,下載后,不能直接整合到專案 問題1.多次拍攝視頻崩潰 問題2.雙擊record按鈕, ......

    uj5u.com 2020-09-10 07:00:50 more
  • Android 開發技術周報 Issue#293

    新聞 谷歌為Android TV開發者提供多種新功能 Android 11將自動填表功能整合到鍵盤輸入建議中 谷歌宣布Android Auto即將支持更多的導航和數字停車應用 谷歌Pixel 5只有XL版本 搭載驍龍765G且將比Pixel 4更便宜 [圖]Wear OS將迎來重磅更新:應用啟動時間 ......

    uj5u.com 2020-09-10 07:01:38 more
  • 海豚星空掃碼投屏 Android 接收端 SDK 集成 六步驟

    掃碼投屏,開放網路,獨占設備,不需要額外下載軟體,微信掃碼,發現設備。支持標準DLNA協議,支持倍速播放。視頻,音頻,圖片投屏。好點意思。還支持自定義基于 DLNA 擴展的操作動作。好像要收費,沒體驗。 這里簡單記錄一下集成程序。 一 跟目錄的build.gradle添加私有mevan倉庫 mave ......

    uj5u.com 2020-09-10 07:01:43 more
最新发布
  • 歡迎頁輪播影片

    如圖,引導開始,球從上落下,同時淡入文字,然后文字開始輪播,最后一頁時停止,點擊進入首頁。 在來看看效果圖。 重力球先不講,主要歡迎輪播簡單實作 首先新建一個類 TextTranslationXGuideView,用于影片展示 文本是類似的,最后會有個圖片箭頭影片,布局很簡單,就是一個 TextVi ......

    uj5u.com 2023-04-20 08:40:31 more
  • 【FAQ】關于華為推送服務因營銷訊息頻次管控導致服務通訊類訊息

    一. 問題描述 使用華為推送服務下發IM訊息時,下發訊息請求成功且code碼為80000000,但是手機總是收不到訊息; 在華為推送自助分析(Beta)平臺查看發現,訊息發送觸發了頻控。 二. 問題原因及背景 2023年1月05日起,華為推送服務對咨詢營銷類訊息做了單個設備每日推送數量上限管理,具體 ......

    uj5u.com 2023-04-20 08:40:11 more
  • 歡迎頁輪播影片

    如圖,引導開始,球從上落下,同時淡入文字,然后文字開始輪播,最后一頁時停止,點擊進入首頁。 在來看看效果圖。 重力球先不講,主要歡迎輪播簡單實作 首先新建一個類 TextTranslationXGuideView,用于影片展示 文本是類似的,最后會有個圖片箭頭影片,布局很簡單,就是一個 TextVi ......

    uj5u.com 2023-04-20 08:39:36 more
  • 【FAQ】關于華為推送服務因營銷訊息頻次管控導致服務通訊類訊息

    一. 問題描述 使用華為推送服務下發IM訊息時,下發訊息請求成功且code碼為80000000,但是手機總是收不到訊息; 在華為推送自助分析(Beta)平臺查看發現,訊息發送觸發了頻控。 二. 問題原因及背景 2023年1月05日起,華為推送服務對咨詢營銷類訊息做了單個設備每日推送數量上限管理,具體 ......

    uj5u.com 2023-04-20 08:39:13 more
  • iOS從UI記憶體地址到讀取成員變數(oc/swift)

    開發除錯時,我們發現bug時常首先是從UI顯示發現例外,下一步才會去定位UI相關連的資料的。XCode有給我們提供一系列debug工具,但是很多人可能還沒有形成一套穩定的除錯流程,因此本文嘗試解決這個問題,順便提出一個暴論:UI顯示例外問題只需要兩個步驟就能完成定位作業的80%: 定位例外 UI 組 ......

    uj5u.com 2023-04-19 09:16:23 more
  • FIDE重磅更新!性能飛躍!體驗有禮!

    FIDE 開發者工具重構升級啦!實作500%性能提升,誠邀體驗! 一直以來不少開發者朋友在社區反饋,在使用 FIDE 工具的程序中,時常會遇到諸如加載不及時、代碼預覽/渲染性能不如意的情況,十分影響開發體驗。 作為技術團隊,我們深知一件趁手的開發工具對開發者的重要性,因此,在2023年開年,FinC ......

    uj5u.com 2023-04-19 09:16:15 more
  • 游戲內嵌社區服務開放,助力開發者提升玩家互動與留存

    華為 HMS Core 游戲內嵌社區服務提供快速訪問華為游戲中心論壇能力,支持玩家直接在游戲內瀏覽帖子和交流互動,助力開發者擴展內容生產和觸達的場景。 一、為什么要游戲內嵌社區? 二、游戲內嵌社區的典型使用場景 1、游戲內打開論壇 您可以在游戲內繪制論壇入口,為玩家提供沉浸式發帖、瀏覽、點贊、回帖、 ......

    uj5u.com 2023-04-19 09:15:46 more
  • iOS從UI記憶體地址到讀取成員變數(oc/swift)

    開發除錯時,我們發現bug時常首先是從UI顯示發現例外,下一步才會去定位UI相關連的資料的。XCode有給我們提供一系列debug工具,但是很多人可能還沒有形成一套穩定的除錯流程,因此本文嘗試解決這個問題,順便提出一個暴論:UI顯示例外問題只需要兩個步驟就能完成定位作業的80%: 定位例外 UI 組 ......

    uj5u.com 2023-04-19 09:14:53 more
  • FIDE重磅更新!性能飛躍!體驗有禮!

    FIDE 開發者工具重構升級啦!實作500%性能提升,誠邀體驗! 一直以來不少開發者朋友在社區反饋,在使用 FIDE 工具的程序中,時常會遇到諸如加載不及時、代碼預覽/渲染性能不如意的情況,十分影響開發體驗。 作為技術團隊,我們深知一件趁手的開發工具對開發者的重要性,因此,在2023年開年,FinC ......

    uj5u.com 2023-04-19 09:14:08 more
  • 游戲內嵌社區服務開放,助力開發者提升玩家互動與留存

    華為 HMS Core 游戲內嵌社區服務提供快速訪問華為游戲中心論壇能力,支持玩家直接在游戲內瀏覽帖子和交流互動,助力開發者擴展內容生產和觸達的場景。 一、為什么要游戲內嵌社區? 二、游戲內嵌社區的典型使用場景 1、游戲內打開論壇 您可以在游戲內繪制論壇入口,為玩家提供沉浸式發帖、瀏覽、點贊、回帖、 ......

    uj5u.com 2023-04-19 09:08:34 more