I have defined a List View in xml as below
<ListView android:id="@+id/mylist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:cacheColorHint="#00000000"
android:layout_weight="1"
android:layout_marginTop="95dip"/>
And i need to re-define the layout margin upon some result in my programe ,how i can achieve this
More simply, you may be able to modify the existing MarginLayoutParams instance to modify the margin:
ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) mListView
.getLayoutParams();
mlp.setMargins(adjustmentPxs, 0, 0, 0);
break;
如果你在Activity中获得了ListView对象,你可以使用方法setLayoutParams() ,传入android.view.ViewGroup.MarginLayoutParams的实例。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.