国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Android基礎(chǔ)到進階UI祖父級 ViewGroup介紹+實用

這篇具有很好參考價值的文章主要介紹了Android基礎(chǔ)到進階UI祖父級 ViewGroup介紹+實用。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

int sizeHeight = MeasureSpec.getSize(heightMeasureSpec);

int modeWidth = MeasureSpec.getMode(widthMeasureSpec);

int modeHeight = MeasureSpec.getMode(heightMeasureSpec);

// 如果是warp_content情況下,記錄寬和高

int width = 0;

int height = 0;

//記錄每一行的寬度,width不斷取最大寬度

int lineWidth = 0;

//每一行的高度,累加至height

int lineHeight = 0;

int count = getChildCount();

int left = getPaddingLeft();

int top = getPaddingTop();

// 遍歷每個子元素

for (int i = 0; i < count; i++) {

View child = getChildAt(i);

if (child.getVisibility() == GONE)

continue;

// 測量每一個child的寬和高

measureChild(child, widthMeasureSpec, heightMeasureSpec);

// 得到child的lp

ViewGroup.LayoutParams lp = child.getLayoutParams();

// 當(dāng)前子空間實際占據(jù)的寬度

int childWidth = child.getMeasuredWidth() + childHorizontalSpace;

// 當(dāng)前子空間實際占據(jù)的高度

int childHeight = child.getMeasuredHeight() + childVerticalSpace;

if (lp != null && lp instanceof MarginLayoutParams) {

MarginLayoutParams params = (MarginLayoutParams) lp;

childWidth += params.leftMargin + params.rightMargin;

childHeight += params.topMargin + params.bottomMargin;

}

//如果加入當(dāng)前child,則超出最大寬度,則的到目前最大寬度給width,類加height 然后開啟新行

if (lineWidth + childWidth > sizeWidth - getPaddingLeft() - getPaddingRight()) {

width = Math.max(lineWidth, childWidth);// 取最大的

lineWidth = childWidth; // 重新開啟新行,開始記錄

// 疊加當(dāng)前高度,

height += lineHeight;

// 開啟記錄下一行的高度

lineHeight = childHeight;

child.setTag(new Location(left, top + height, childWidth + left - childHorizontalSpace, height + child.getMeasuredHeight() + top));

} else {

// 否則累加值lineWidth,lineHeight取最大高度

child.setTag(new Location(lineWidth + left, top + height, lineWidth + childWidth - childHorizontalSpace + left, height + child.getMeasuredHeight() + top));

lineWidth += childWidth;

lineHeight = Math.max(lineHeight, childHeight);

}

}

width = Math.max(width, lineWidth) + getPaddingLeft() + getPaddingRight();

height += lineHeight;

sizeHeight += getPaddingTop() + getPaddingBottom();

height += getPaddingTop() + getPaddingBottom();

setMeasuredDimension((modeWidth == MeasureSpec.EXACTLY) ? sizeWidth : width, (modeHeight == MeasureSpec.EXACTLY) ? sizeHeight : height);

}

/**

  • 記錄子控件的坐標(biāo)

*/

public class Location {

public Location(int left, int top, int right, int bottom) {

this.left = left;

this.top = top;

this.right = right;

this.bottom = bottom;

}

public int left;

public int top;

public int right;

public int bottom;

}

//計算當(dāng)前View以及子View的位置

@Override

protected void onLayout(boolean changed, int l, int t, int r, int b) {

MLog.e(getClass().getName(),“onLayout”);

//獲取子View個數(shù)

int count = getChildCount();

for (int i = 0; i < count; i++) {

//獲取子View

View child = getChildAt(i);

//判斷是否顯示

if (child.getVisibility() == GONE)

continue;

//獲取子View的坐標(biāo)

Location location = (Location) child.getTag();

//設(shè)置子View位置

child.layout(location.left, location.top, location.right, location.bottom);

}

}

@Override

protected void onSizeChanged(int w, int h, int oldw, int oldh) {

super.onSizeChanged(w, h, oldw, oldh);

MLog.e(getClass().getName(),“onSizeChanged”);

}

@Override

protected void onDraw(Canvas canvas) {

super.onDraw(canvas);

MLog.e(getClass().getName(),“onDraw”);

}

}

2.使用自定義CustomLayout

<?xml version="1.0" encoding="utf-8"?>

<com.scc.demo.view.CustomLayout xmlns:android=“http://schemas.android.com/apk/res/android”

xmlns:custom=“http://schemas.android.com/apk/res-auto”

android:layout_width=“match_parent”

android:layout_height=“match_parent”

android:layout_margin=“@dimen/dimen_20”

custom:horizontalSpace=“10dp”

custom:verticalSpace=“20dp”>

<TextView

style=“@style/TvStyle”

android:text=“破陣子·為陳同甫賦壯詞以寄” />

<TextView

style=“@style/TvStyle”

android:text=“宋·辛棄疾” />

<TextView

style=“@style/TvStyle”

android:text=“醉里挑燈看劍” />

<TextView

style=“@style/TvStyle”

android:text=“夢回吹角連營” />

<TextView

style=“@style/TvStyle”

android:text=“八百里分麾下炙” />

<TextView

style=“@style/TvStyle”

android:text=“五十弦翻塞外聲” />

<TextView

style=“@style/TvStyle”

android:text=“沙場秋點兵” />

<TextView

style=“@style/TvStyle”

android:text=“馬作的盧飛快” />

<TextView

style=“@style/TvStyle”

android:text=“弓如霹靂弦驚(增加點長度)” />

<TextView

style=“@style/TvStyle”

android:text=“了卻君王天下事” />

<TextView

style=“@style/TvStyle”

android:text=“贏得生前身后名” />

<TextView

style=“@style/TvStyle”

android:text=“可憐白發(fā)生!” />

</com.scc.demo.view.CustomLayout>

自定義屬性

在app/src/main/res/values/attrs.xml中添加屬性

<?xml version="1.0" encoding="utf-8"?>

使用自定義屬性

  • 在xml中使用

一定要添加:xmlns:test=”schemas.android.com/apk/res-aut…

<com.scc.demo.view.CustomLayout xmlns:android=“http://schemas.android.com/apk/res/android”

xmlns:custom=“http://schemas.android.com/apk/res-auto”

android:layout_width=“match_parent”

android:layout_height=“match_parent”

android:layout_margin=“@dimen/dimen_20”

custom:horizontalSpace=“10dp”

custom:verticalSpace=“20dp”>

</com.scc.demo.view.CustomLayout>

自我介紹一下,小編13年上海交大畢業(yè),曾經(jīng)在小公司待過,也去過華為、OPPO等大廠,18年進入阿里一直到現(xiàn)在。

深知大多數(shù)Android工程師,想要提升技能,往往是自己摸索成長或者是報班學(xué)習(xí),但對于培訓(xùn)機構(gòu)動則幾千的學(xué)費,著實壓力不小。自己不成體系的自學(xué)效果低效又漫長,而且極易碰到天花板技術(shù)停滯不前!

因此收集整理了一份《2024年Android移動開發(fā)全套學(xué)習(xí)資料》,初衷也很簡單,就是希望能夠幫助到想自學(xué)提升又不知道該從何學(xué)起的朋友,同時減輕大家的負擔(dān)。
Android基礎(chǔ)到進階UI祖父級 ViewGroup介紹+實用,2024年程序員學(xué)習(xí),android,ui
Android基礎(chǔ)到進階UI祖父級 ViewGroup介紹+實用,2024年程序員學(xué)習(xí),android,ui
Android基礎(chǔ)到進階UI祖父級 ViewGroup介紹+實用,2024年程序員學(xué)習(xí),android,ui
Android基礎(chǔ)到進階UI祖父級 ViewGroup介紹+實用,2024年程序員學(xué)習(xí),android,ui
Android基礎(chǔ)到進階UI祖父級 ViewGroup介紹+實用,2024年程序員學(xué)習(xí),android,ui
Android基礎(chǔ)到進階UI祖父級 ViewGroup介紹+實用,2024年程序員學(xué)習(xí),android,ui
Android基礎(chǔ)到進階UI祖父級 ViewGroup介紹+實用,2024年程序員學(xué)習(xí),android,ui

既有適合小白學(xué)習(xí)的零基礎(chǔ)資料,也有適合3年以上經(jīng)驗的小伙伴深入學(xué)習(xí)提升的進階課程,基本涵蓋了95%以上Android開發(fā)知識點,真正體系化!

由于文件比較大,這里只是將部分目錄大綱截圖出來,每個節(jié)點里面都包含大廠面經(jīng)、學(xué)習(xí)筆記、源碼講義、實戰(zhàn)項目、講解視頻,并且后續(xù)會持續(xù)更新

如果你覺得這些內(nèi)容對你有幫助,可以添加V獲取:vip204888 (備注Android)
Android基礎(chǔ)到進階UI祖父級 ViewGroup介紹+實用,2024年程序員學(xué)習(xí),android,ui

最后

由于文章篇幅原因,我只把面試題列了出來,詳細的答案,我整理成了一份PDF文檔,這份文檔還包括了還有?高級架構(gòu)技術(shù)進階腦圖、Android開發(fā)面試專題資料,高級進階架構(gòu)資料 ,幫助大家學(xué)習(xí)提升進階,也節(jié)省大家在網(wǎng)上搜索資料的時間來學(xué)習(xí)。

mg.cn/13f2cb2e05a14868a3f0fd6ac81d625c.png)

既有適合小白學(xué)習(xí)的零基礎(chǔ)資料,也有適合3年以上經(jīng)驗的小伙伴深入學(xué)習(xí)提升的進階課程,基本涵蓋了95%以上Android開發(fā)知識點,真正體系化!

由于文件比較大,這里只是將部分目錄大綱截圖出來,每個節(jié)點里面都包含大廠面經(jīng)、學(xué)習(xí)筆記、源碼講義、實戰(zhàn)項目、講解視頻,并且后續(xù)會持續(xù)更新

如果你覺得這些內(nèi)容對你有幫助,可以添加V獲?。簐ip204888 (備注Android)
[外鏈圖片轉(zhuǎn)存中…(img-cP86rkm4-1711917793602)]

最后

由于文章篇幅原因,我只把面試題列了出來,詳細的答案,我整理成了一份PDF文檔,這份文檔還包括了還有?高級架構(gòu)技術(shù)進階腦圖、Android開發(fā)面試專題資料,高級進階架構(gòu)資料 ,幫助大家學(xué)習(xí)提升進階,也節(jié)省大家在網(wǎng)上搜索資料的時間來學(xué)習(xí)。

本文已被CODING開源項目:《Android學(xué)習(xí)筆記總結(jié)+移動架構(gòu)視頻+大廠面試真題+項目實戰(zhàn)源碼》收錄文章來源地址http://www.zghlxwxcb.cn/news/detail-853049.html

到了這里,關(guān)于Android基礎(chǔ)到進階UI祖父級 ViewGroup介紹+實用的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • Android ViewGroup onDraw為什么沒調(diào)用

    Android ViewGroup onDraw為什么沒調(diào)用

    ViewGroup,它本身并沒有任何可畫的東西,它是一個透明的控件,因些并不會觸發(fā)onDraw,但是你現(xiàn)在給LinearLayout設(shè)置一個背景色,其實這個背景色不管你設(shè)置成什么顏色,系統(tǒng)會認為,這個LinearLayout上面有東西可畫了,因此會調(diào)用onDraw方法。 android代碼一直在優(yōu)化,我看了幾個

    2024年02月16日
    瀏覽(23)
  • Android----GitHub上25個超炫酷又實用的開源UI框架,強烈建議收藏!

    Android----GitHub上25個超炫酷又實用的開源UI框架,強烈建議收藏!

    分類側(cè)滑菜單,Yalantis 出品。 項目地址:https://github.com/Yalantis/Side-Menu.Android 2.Context-Menu.Android 可以方便快速集成漂亮帶有動畫效果的上下文菜單,Yalantis出品。 項目地址:https://github.com/Yalantis/Context-Menu.Android 3.Pull-to-Refresh.Rentals-Android 提供一個簡單可以自定義的下拉刷新實現(xiàn)

    2024年03月23日
    瀏覽(152)
  • Android架構(gòu)進階之高級UI系列(精編解析,值得收藏)

    Android架構(gòu)進階之高級UI系列(精編解析,值得收藏)

    public FrameHandler(Looper looper) { super(looper); } @Override public void handleMessage(Message msg) { switch (msg.what) { case MSG_DO_FRAME: // 執(zhí)行doFrame // 如果啟用VSYNC機制,當(dāng)VSYNC信號到來時觸發(fā) doFrame(System.nanoTime(), 0); break; case MSG_DO_SCHEDULE_VSYNC: // 申請VSYNC信號,例如當(dāng)前需要繪制任務(wù)時 doScheduleVsync()

    2024年04月14日
    瀏覽(28)
  • Vue教學(xué)17:Element UI基礎(chǔ)組件上手,打造美觀實用的Vue應(yīng)用

    大家好,歡迎回到我們的Vue教學(xué)系列博客!在前十六篇博客中,我們學(xué)習(xí)了Vue.js的基礎(chǔ)知識、安裝Node.js與npm、使用Vue Devtools進行調(diào)試、Vue實例與生命周期鉤子、數(shù)據(jù)綁定(單向與雙向)、計算屬性與偵聽器、條件渲染和列表渲染、事件處理、組件之間的傳值(props和$emit)、

    2024年04月14日
    瀏覽(25)
  • Android-高級-UI-進階之路(四)-Paint-渲染-濾鏡-xfermode-使用

    Android-高級-UI-進階之路(四)-Paint-渲染-濾鏡-xfermode-使用

    class MyGradientView : View { private var mPaint: Paint? = null private var mBitMap: Bitmap? = null private var mWidth: Int = 0 private var mHeight: Int = 0 private val mColors = intArrayOf(Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW) constructor(context: Context?) : super(context) { init() } constructor(context: Context?, attrs: AttributeSet?) : super(

    2024年04月16日
    瀏覽(30)
  • QT-------UI基礎(chǔ)到進階,干貨滿滿?。。? decoding=

    QT-------UI基礎(chǔ)到進階,干貨滿滿!??!

    目錄 一、UI基礎(chǔ) 1. QWidget類(掌握) 2. 添加子組件(掌握) 3. 樣式表(熟悉) 二、UI進階 1. Designer 設(shè)計師(掌握) 2. 布局 Layout(掌握) 3. QWidget屬性(掌握) 4. UI指針(掌握) 5. 基礎(chǔ)組件(熟悉) 5.1 標(biāo)簽 QLabel 5.2 按鈕類 5.3 單行文本編輯框 QLineEdit 5.4 組合框 QComboBox 5.5 一

    2024年02月04日
    瀏覽(21)
  • 【Android進階篇】Android中PreferenceScreen的作用和詳細用法介紹

    【Android進階篇】Android中PreferenceScreen的作用和詳細用法介紹

    1, PreferenceScreen的作用 在Android開發(fā)中,PreferenceScreen是一個非常重要的布局控件,主要用于創(chuàng)建設(shè)置界面(settings page)。它可以包含多個Preference子項,如CheckBoxPreference, ListPreference等,用于設(shè)置應(yīng)用程序的各種選項。 以下是一些關(guān)于PreferenceScreen的詳細使用說明: 1, 創(chuàng)建設(shè)

    2024年02月21日
    瀏覽(42)
  • Android-高級-UI-進階之路-(二)-深入理解-Android-8-0-View-觸摸事件分發(fā)機制,查漏補缺

    Android-高級-UI-進階之路-(二)-深入理解-Android-8-0-View-觸摸事件分發(fā)機制,查漏補缺

    我們看到內(nèi)部又調(diào)用了父類 dispatchTouchEvent 方法, 所以最終是交給 ViewGroup 頂級 View 來處理分發(fā)了。 頂級 View 對點擊事件的分發(fā)過程 在上一小節(jié)中我們知道了一個事件的傳遞流程,這里我們就大致在回顧一下。首先點擊事件到達頂級 ViewGroup 之后,會調(diào)用自身的 dispatchTouchE

    2024年04月14日
    瀏覽(39)
  • Canvas中的裁剪師講解與實戰(zhàn)——Android高級UI(1),Android體系化進階學(xué)習(xí)圖譜

    Canvas中的裁剪師講解與實戰(zhàn)——Android高級UI(1),Android體系化進階學(xué)習(xí)圖譜

    從今天開始我們聊一聊 Canvas 的API,因為Canvas的API較多,所以我們分為幾次分享,首先分享的是裁剪類型的API使用。話不多說,先上實戰(zhàn)圖。 老夫的少女心 源碼地址文末會給出,了解原理才能更好地駕馭。 分享前,我們先來聊聊,在我們生活中如何繪制一張如下的圖。 我們

    2024年04月13日
    瀏覽(41)
  • Android-高級-UI-進階之路-(五)-看完該篇文章-Canvas-你應(yīng)該會了

    Android-高級-UI-進階之路-(五)-看完該篇文章-Canvas-你應(yīng)該會了

    /** 1. 繪制橢圓 */ canvas.drawOval(RectF(100f,500f,600f,800f),mPaint) /** 2. 繪制圓 */ mPaint.setColor(Color.YELLOW) mPaint.alpha = 100 canvas.drawCircle(400f,400f,200f,mPaint) 繪制 Bitmap // val bitmap = BitmapFactory.decodeResource(context.resources, R.mipmap.gild_3) //第二個,第三個參數(shù)代表起點位置 canvas.drawBitmap(bitmap,100f,100

    2024年03月28日
    瀏覽(11)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包