0

layout.xml コード部分:

<ListView
    android:id="@+android:id/listWhatever"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="@id/rlSomething" 
    android:layout_marginBottom="I need this to set in code dinamically!"/>

Java コード部分:

listWhatever = (ListView)findViewById(R.id.listWhatever);
RelativeLayout.LayoutParams layoutParams = (LayoutParams) listWhatever.getLayoutParams();

layoutParams.addRule(android:layout_marginBottom ... , how?);
4

2 に答える 2

1

これを試して:

 LayoutParams lp= (LayoutParams) list.getLayoutParams();
 lp.setMargins(left, top, right, bottom);
 list.setLayoutParams(lp);
于 2013-10-31T19:42:57.000 に答える