OC 相對布局

2021-08-15 22:38:14 字數 1455 閱讀 1291

頁面裡乙個uitableview,然後uitableview下面有乙個button,想要實現的效果,當uitableview的高度改變時,保證button和uitableview的豎直間距不變。

實現:

給uitableview設定高度約束,給乙個預設的高度值160(因為這裡初始化顯示4個cell,每個高度40),然後control到 viewcontroller裡面去,動態修改uitableview的高度約束值即可。

nsinteger k=4;//預設顯示4個cell

- (ibaction)load:(id)sender

- (void)viewdidload

- (void)didreceivememorywarning

- (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section

- (nsinteger)numberofsectionsintableview:(uitableview *)tableview

- (uitableviewcell*)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath

//cell選中效果

cell.selectionstyle = uitableviewcellselectionstylenone;

cell.textlabel.text = @"test";

cell.textlabel.textcolor = [uicolor whitecolor];

return cell;

}//行高

- (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath

@end

Android布局(相對布局)

relativelayout相對布局裡常用的位置屬性 2.id型xml屬性 android layout above 該元件位於引用元件的上方 android layout below 該元件位於引用元件的下方 android layout toleftof 該元件位於引用元件的左方 android...

Android相對布局

2 相對布局 如圖 梅花布局 如下 android layout width match parent android layout height match parent android id id no.0 android layout width wrap content android la...

RelativeLayout相對布局

relativelayout相對布局是個人覺得在android布局中比較常用且好用的乙個,當然如果想讓布局更漂亮是需要多種布局混合搭建的,這裡就需要更深入的學習了,在這只介紹下有關相對布局的東西。相對於兄弟元素 android layout below id aaa 在指定view的下方 andro...