/**設定專題的大小比例,都是一樣的比例寬高*/
public class rationlayout extends framelayout
public rationlayout(context context, attributeset attrs)
private void setratio(float ratio)
public rationlayout(context context)
float rotio;//比例
private int width;
private int height;
//父容器(viewgroup的測量規則)
@override
protected void onmeasure(int widthmeasurespec, int heightmeasurespec) else if(widthmode!=measurespec.exactly&&heightmode==measurespec.exactly)
//重新制定乙個測量規則
widthmeasurespec = measurespec.makemeasurespec(
measurespec.exactly,width + getpaddingleft() +getpaddingright());
heightmeasurespec = measurespec.makemeasurespec(
measurespec.exactly,height + getpaddingtop() +getpaddingbottom());
super.onmeasure(widthmeasurespec, heightmeasurespec);
}}
2.自定義屬性,設定比例
①.設定attrs下的xml
②.獲取屬性//設定集合名字
//設定特定的屬性名字
public rationlayout(context context, attributeset attrs)
3.xml中設定ratio屬性的值
});//設定textview包裹內容
linearlayout.addview(textview,new layoutparams(layoutparams.wrap_content, -2));
} scrollview.addview(linearlayout);
return scrollview;
}
public class flowlayout extends viewgroup
public flowlayout(context context, attributeset attrs)
public flowlayout(context context)
private void init()
// viewgroup必須實現的方法。因為要對孩子分配位置
// 怎麼分配位置?----1.對孩子進行測量
// ----2.然後才進行分配位置
// /** 1.對孩子進行測量 */
@override
protected void onmeasure(int widthmeasurespec, int heightmeasurespec)
newline();// 如果使用的行的寬度》行寬,換行
} else
}} if (!lines.contains(currentline))
// 行的總高度
int totalheight = 0;
for (line line : lines)
totalheight += (lines.size() - 1) * verticalspace+getpaddingbottom()+getpaddingtop();// 加上行的間隔
// 按照自己的寬高去設定
setmeasureddimension(width+getpaddingleft()+getpaddingright(), resolvesize(totalheight, heightmeasurespec));
} /** 2.分配位置 */
@override
protected void onlayout(boolean changed, int l, int t, int r, int b)
} private listlines = new arraylist();// 所有行的集合
private line currentline;// 當前行
private int usewidth = 0;// 使用的行的寬度
private int horizontalspace = uiutils.dip2px(13);
private int verticalspace = uiutils.dip2px(13);
private int width;
private int height;
class line
children.add(child);
linewidth += child.getmeasuredwidth();
} // 該行的textview的個數
public int getchildcount()
// 分配孩子的位置
public void layout(int l, int t)
}for (int i = 0; i < children.size(); i++)
} // 獲得行的高度
public int getheight()
} /** 換行 */
private void newline()
}
未來最大消費電子市場是東歐波蘭
波蘭 創新的代名詞 消費電子不僅是波蘭,甚至是世界上增長速度快的行業之一。近年來,消費電子的銷售額佔整個波蘭經濟中保持著2.9 的增長,目前在顯示器材 燈光音響 智慧型裝置等消費電子方面的消費者遠遠優秀於中歐和東歐其他國家。根據國際專家 消費電子市場的價值將會保持持續穩定增長,家用電子行業也將呈顯著...
管中窺豹 從電子市場看安防行業的變與不變
電子市場,一直都是專業安防產品的聚集地和流通地,比如頤高電子城 賽格電子市場,裡面匯聚了各種型別 各種品牌的安防產品,而且許多受關注安防產品一定在店鋪最顯眼的位置。可以說,電子市場中安防產品的陳列和安防店面的興衰能反應出當地安防市場和目前行業發展的現象。機智如筆者,借助百城會的機會,在各個會議城市 ...
時代周刊 谷歌微軟爭奪高校電子郵件外包市場
泛東協同,贏在執行!開闢新戰場 大學生經常都會抱怨學校提供的電子郵件服務空間太小,無法處理大量郵件和附件。為了解決這一問題,有越來越多的大學和學院開始將電子郵件外包出去。又有哪些公司願意為這些高校提供免費的電子郵件服務呢?答案是谷歌和微軟。繼搜尋 軟體和作業系統之後,大學校園成為這兩家科技巨頭的又乙...