android listview display all available items without scroll with static header

前端 未结 12 632
一生所求
一生所求 2020-12-02 10:12

I\'m having a little difficulties while trying to get a certain layout to work: I want to have list. List does not have to be scrollable, but should be shown completely. But

12条回答
  •  死守一世寂寞
    2020-12-02 10:35

    If all items has the same height

            int totalItemsHeight = baseDictionaries.size() * item.getMeasuredHeight();
            int totalDividersHeight = listView.getDividerHeight() * (baseDictionaries.size() - 1);
            int totalPadding = listView.getPaddingBottom() + listView.getPaddingTop();
    
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) listTranslationWords.getLayoutParams();
            lp.height = totalItemsHeight + totalDividersHeight + totalPadding;
            listTranslationWords.setLayoutParams(lp);
    

提交回复
热议问题