2016-06-14 62 views
0

我有一個scrollview,裏面有一個gridlayout視圖。在該網格佈局中,每個項目都有一個帶有複選框的列表。無論何時用戶選擇一個項目,最下面一行應該緩慢展開並顯示所選項目的詳細信息。這是我與boxview的嘗試,但它不起作用。任何建議如何解決這個問題?緩慢擴展Gridlayout的行

void OnChanged(object sender, EventArgs e) 
    { 
     if (statusBar == null) 
     { 
      statusBar = new BoxView { Color = Color.FromHex("#33B5E5"), HeightRequest = 0 }; 
      mainGrid.Children.Add(statusBar, 0, 4); 
      Grid.SetColumnSpan(statusBar, 2); 

      var animate = new Animation(d => statusBar.HeightRequest = d, 1, statusBar.Height, Easing.SpringIn); 

      animate.Commit(this, "a"); 
     } 

     if (((CheckBox)sender).Checked) 
      checkedCount++; 
     else 
      checkedCount--; 

     if(checkedCount == 0) 
     { 
      mainGrid.Children.Remove(statusBar); 
      statusBar = null; 
      return; 
     } 
    } 

UPDATE:

這仍然無法正常工作。 boxview立即顯示

所以我改變了我的代碼,每個建議:

statusBar = new BoxView { Color = Color.FromHex("#33B5E5"), HeightRequest = 0 }; 
      mainGrid.Children.Add(statusBar, 0, 4); 
      Grid.SetColumnSpan(statusBar, 2); 

      var animate = new Animation(d => statusBar.HeightRequest = d, 1, 1000, Easing.SpringIn); 
      animate.Commit(this, "a", length: 10000);//animation takes 2 sec to complete 

回答

0

添加一些時間,你的動畫。

animate.Commit(this, "a",length:2000);//animation takes 2 sec to complete 

我不明白你的代碼。

var animate = new Animation(d => statusBar.HeightRequest = d, 1, statusBar.Height, Easing.SpringIn); 

您設定的高度以上 HeightRequest = 0和開始你的動畫和0這將可能close您BoxView中結束。嘗試在end屬性中添加較大的值以獲得所需的動畫,例如

var animate = new Animation(d => statusBar.HeightRequest = d, 1, 100, Easing.SpringIn); 
+0

所以我更新了我的代碼,但boxview顯示而不是動畫。 – user30646

+0

增加時間長度:4000或任何期望的值。 –

+0

它設置爲10,000。 – user30646