0

How can I set the top padding of a ListView programmatically? With SetPadding() nothing happens with the listView while doing it in axml with android:paddingTop="100dp" works great.

In other words; how can I implement android:paddingTop="100dp" in code?

Why I need it?: I need the padding for design/interaction reasons and it works great if I set it in axml. But the size/value needs to be the exact same size of another view (because of design/interaction reasons) I need to set it in code. And I discovered the ListView.paddingTop property in the background sets the ListPaddingTop of the ListView, I tried looking for the answer in there but I couldn’t find any solution for setting that property either.

I currently use this axml setup:

    <ListView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:paddingTop="100dp"
    android:scrollbarStyle="outsideOverlay"
    android:clipToPadding="false" />
Toine db
  • 709
  • 7
  • 25
  • use View#setPadding(int, int, int, int) properly, most likely you misused it – pskink Jun 04 '15 at 06:38
  • @pskink yep, I'm using/inheriting from a ListView coming from MVVMCross and that seems to set things in it constructor what I can't control. – Toine db Jun 05 '15 at 08:37

0 Answers0