Skip to content

Instantly share code, notes, and snippets.

@Reacoder
Created July 24, 2014 10:00
Show Gist options
  • Save Reacoder/e11d2f3eaed2ae8654bf to your computer and use it in GitHub Desktop.
Save Reacoder/e11d2f3eaed2ae8654bf to your computer and use it in GitHub Desktop.
动态改变margin 布局。
private void moveUserInfoLayoutInY(int marginTop) {
MarginLayoutParams marginParams = new MarginLayoutParams(mUserInfoLayout.getLayoutParams());
float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, marginTop, getResources().getDisplayMetrics());
marginParams.setMargins((int)mUserInfoLayout.getLeft(), (int)px, 0, 0);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(marginParams);
mUserInfoLayout.setLayoutParams(layoutParams);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment