[英]Android View With ListView Doesn't Grow
我有一個用自定義視圖動態填充的LinearLayout(偽代碼):
<LinearLayout>
自定義視圖只是這樣的LinearLayout(偽代碼):
<LinearLayout>
<TextView>
<ListView width="match_parent" height="match_parent">
</LinearLayout>
當父級顯示時,它僅顯示每個自定義視圖的TextView和ListView的第一行。 我有什么辦法可以使自定義視圖擴展為顯示ListView中的所有項目?
(值得注意的是,我計划使每個自定義視圖像手風琴一樣……可擴展/可折疊)
我最終使用了Android.Animation命名空間/程序包,並使用ValueAnimator為我一直在尋找的展開/折疊行為設置了動畫:
ValueAnimator animator = null;
if (expanded) {
handle.SetImageResource(Android.Resource.Drawable.ArrowDownFloat);
animator = ValueAnimator.OfObject (new HeightEvaluator (listView), height, 0);
} else {
handle.SetImageResource(Android.Resource.Drawable.ArrowUpFloat);
animator = ValueAnimator.OfObject (new HeightEvaluator (listView), 0, height);
}
animator.SetDuration(500);
animator.SetInterpolator(new AccelerateInterpolator (1));
animator.Start ();
expanded = !expanded;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.