您好,登錄后才能下訂單哦!
關(guān)于View的屬性
自定義動(dòng)態(tài)設(shè)置View的大小屬性
使用LayoutParams來(lái)設(shè)置view的寬高.
int textLen = AddShopActivity.mCategoryItemNames1[type][textPos].length(); final int dimension = (int) (getResources().getDimension(R.dimen.text_size)); int left = dimension * textLen + (int) (getResources().getDimension(R.dimen.rl_left)); RelativeLayout.LayoutParams lp2 = new LayoutParams(left + (int) (getResources().getDimension(R.dimen.rl_right)), (int) (getResources().getDimension(R.dimen.rl_height))); lp2.setMargins(0, (int) (getResources().getDimension(R.dimen.rl_top)), 0, (int) (getResources().getDimension(R.dimen.rl_top))); mRL01.setLayoutParams(lp2); mDeleteBt = (Button) mRLMain.findViewById(R.id.deletebt); MarginLayoutParams marginsParams = new MarginLayoutParams( mDeleteBt.getLayoutParams()); marginsParams.setMargins(left, 0, 0, 0); RelativeLayout.LayoutParams lp = new LayoutParams(marginsParams);
ViewGroup內(nèi)部View的圖層關(guān)系
bar.bringToFront();
在辛顯龍Blog中是這樣解釋的: Android中的ViewGroup是通過(guò)一個(gè)Array來(lái)保存其Children,當(dāng)調(diào)用某個(gè)childView的bringToFront時(shí),是將該childView放在其Parent的Array數(shù)組的最后,ViewGroup的dispatchDraw在draw時(shí)是按照Array從前往后依次調(diào)用drawChild的,這樣最后一個(gè)childView就在最前面了。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。