Android. Align xml-layout view according view created from code
I create a button from code and places it on bottom of rootView
RelativeLayout.LayoutParams buttonParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
buttonParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
rootView.addView(getSaveButton(), buttonParams);
In xml layout I have a list that height = wrap_content. I want align list bottom with button top when button is created.
<ExpandableListView
android:id="@+id/episodes_list"
开发者_如何学Go android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:layout_below="@id/show_status_buttons_layout"
android:groupIndicator="@drawable/indicator"
/>
How I can add android:layout_above="@id/button_save" layout parameter to ListView? Thanks.
RelativeLayout.LayoutParams listParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
listParams.addRule(RelativeLayout.ABOVE, getSaveButton().getId());
episodesList.setLayoutParams(listParams);
This should work
buttonParams.addRule(RelativeLayout.ABOVE, R.id.button_save);
精彩评论