代碼里設(shè)置子view寬度不起作用
LinearLayout.LayoutParams lp = (LayoutParams) view.getLayoutParams(); ? ? ? ? ? ?lp.weight = 0; ? ? ? ? ? ?lp.weight = getScreenWidth() / mTabVisibleCount; ? ? ? ? ? ?view.setLayoutParams(lp); 這句話為什么我設(shè)置了沒起作用 上面顯示還是九個
LinearLayout.LayoutParams lp = (LayoutParams) view.getLayoutParams(); ? ? ? ? ? ?lp.weight = 0; ? ? ? ? ? ?lp.weight = getScreenWidth() / mTabVisibleCount; ? ? ? ? ? ?view.setLayoutParams(lp); 這句話為什么我設(shè)置了沒起作用 上面顯示還是九個
2016-03-11
舉報
2016-04-20
for(int i=0;i<cCount;i++){
View view=getChildAt(i); ? ??
LinearLayout.LayoutParams lp=(LayoutParams) view.getLayoutParams();
lp.weight=0;
lp.width=0;
lp.width=getScreenWidth()/mTabVisibleCount;
view.setLayoutParams(lp);
Log.e("width",lp.width+"");
}
//我是這么弄得,和老師的代碼對照了很久,就是沒發(fā)現(xiàn)哪里有問題,之后調(diào)試發(fā)現(xiàn)的
2016-03-11
?應(yīng)該是lp.width = getScreenWidth() / mTabVisibleCount;?
你粗心了