文章

build.gradle做類似flutter中的pub get抓pub.dev的lib

 Flutter 支持使用其他開發者向Flutter 和Dart 生態系統貢獻的共享package,這意味著你可以快速構建應用而不是一切從零開始。 Package 和插件(plugin) 有什麼區別呢? 插件(plugin) 是package 的一種,全稱是plugin package,我們簡稱為plugin,中文叫插件。 Packages Dart package 最低要求是包含一個pubspec.yaml文件。此外,一個package 可以包含依賴關係(在pubspec.yaml文件裡聲明)、 Dart 庫、應用、資源、字體、測試、圖片和例子等。 pub.dev上列出了很多package,由Google 工程師和Flutter 和Dart 社區的開發者開發和發布,你可以用在自己的應用裡。 Package 會被發佈到pub.dev網站上。Pub 網站上的Flutter 頁面 展示了與Flutter 兼容的package(即聲明的依賴通常與Flutter 兼容),並且所有已發布的package 都支持搜索。

Layout UI中放 Layout UI

 如圖,這次的範例中有三個layout,分別就是主介面(activity_main),第一介面與第二介面 再來我直接給你三個介面的內容   activity_main.xml 截圖 2020-09-05 下午9.27.37 <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     tools:context=".MainActivity">     <androidx.constraintlayout.widget.ConstraintLayout         android:id="@+id/constraintLayout"         android:layout_width="0dp"         android:layout_height="0dp"         app:layout_constraintBottom_toBottomOf="parent"         app:layout_constraintEnd_toEndOf="parent"         app:layout_constraintStart_to...

搞懂不同Layout之間的差異

圖片
  主要有分為 Linear Layout(線性佈局)、 constraintlayout(約束布局)、 Relative Layout(相對佈局)、 TableLayout(表格佈局)、 AbsoluteLayout(絕對佈局)、 FrameLayout(框架佈局), 每個Layout都有他們的優點,也有他們個別擅長的設計方式。 常用程式碼 layout_height:依需要使用的範圍給大小(wrap_content)、與版面高度一樣大小(match_parent) layout_width:依需要使用的範圍給大小(wrap_content)、與版面寬度一樣大小(match_parent) text:原件內部顯示的文字 textSize:控制文字大小 textStyle:控制文字樣式 <TextView android: id = "@+id/center" //給這個原件一個名子 android:layout_width= "0dp" android:layout_height= "match_parent" //依照原件需要使用多少的高度自動給予 android:layout_weight= "2" android:gravity= "center" //使文字置中 android:text= "置中" android:textSize= "20dp" //文字20dp android:textStyle= "bold" /> //文字粗體 Linear Layout–線性佈局 其線性可分為水平(horizontal)及垂直(vertical),預設是水平佈局,且不管是一行都只能存在一個元件。 常用程式碼 orientation:設定LinearLayout是垂直(vertical)或者...

RecyclerView動態列表 (流程)

圖片
 Data -> RecyclerView -> 生成列表 ViewHolder :  列表中的每個獨立元素都由一個ViewHolder 對象進行定義. 定義Layout(UI)中每個元件中的object variable Adapter: 將View綁定其Data. 將Data list 綁定(binding)到ViewHolder與View(Layout UI) LayoutManager : 負責排列 列表中的各個元素     -  LinearLayoutManager: 類似ListView (Vertical & Horizontal)     - GridLayout Manager: 類似Grid     -  StaggeredGridLayoutManager: 類似瀑布式      Step: 1. Define Layout 2. Data Modal 3. ViewHolder 4. ClickListener 5. Adapter 6. MainActivity - LayoutManager

Can't determine type for tag '?attr/colorSurface'

  That is caused by   1.7.0 : implementation 'com.google.android.material:material:1.7.0' You better stick to  1.6.0  till they fix this implementation 'com.google.android.material:material:1.6.0'

Android studio報錯Could not find method dependencyResolutionManagement() for arguments的解決方法

 build.gradle plugins { id 'com.android.application' } android { namespace 'com.example.newmyapplication' compileSdk 33 defaultConfig { applicationId "com.example.newmyapplication" minSdk 24 targetSdk 33 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile( 'proguard-android-optimize.txt' ), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion. VERSION_1_8 targetCompatibility JavaVersion. VERSION_1_8 } buildFeatures { viewBinding true } } dependencies { implementation 'androidx.appcompat:appcompat:1.0.0' implementation 'com.google.android.material:material:1.6.0' implementation 'androidx.const...

Duplicate class android.support.v4.app.INotificationSideChannel found in modules classes?

圖片
  You can add below 2 lines into your   gradle.properties   file: android.useAndroidX=true android.enableJetifier=true Note  to check, to not repeat any line that already exists (and ensure existing are  true ). Details: Your project (or one of its sub-projects, or a dependency) is no longer using  android.support  libraries and instead is using  androidx  libraries, which causes conflicts if mixed with  android.support  libraries. If you want to use  androidx -namespaced libraries in an old project, you need to set the compile SDK to Android 9.0 (API level 28) or higher but below "API level 31", and set both of the mentioned Android Gradle plugin flags to  true . android.useAndroidX : When this flag is set to  true , the Android plugin uses the appropriate AndroidX library instead of a Support Library. The flag is  false  by default if it is not specified. android.enableJetifier : When this flag is set to...