android - How can I set the top padding of a ListView programmatically? -
how can set top padding of listview programmatically? setpadding() nothing happens listview while doing in axml android:paddingtop="100dp" works great.
in other words; how can implement android:paddingtop="100dp" in code?
why need it?: need padding design/interaction reasons , works great if set in axml. size/value needs exact same size of view (because of design/interaction reasons) need set in code. , discovered listview.paddingtop property in background sets listpaddingtop of listview, tried looking answer in there couldn’t find solution setting property either.
i use 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" />
you can use setpadding (int left, int top, int right, int bottom) listview.setpadding(0,padding,0,0);
this set top padding padding
-pixels.
for set in dp
instead, can conversion:
float scale = getresources().getdisplaymetrics().density; int dpaspixels = (int) (100*scale + 0.5f);
edit:
try code:
view padding = new view(this); padding.setheight(100); listview.addheaderview(padding);
Comments
Post a Comment