布局对应的xml
xmlns:tools=”http://schemas.android.com/tools”
android:layout_width=”match_parent”
android:layout_height=”match_parent”
android:background=”@color/white”
>
android:id=”@+id/tv”
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:gravity=”center”
android:textSize=”18sp”
android:text=”和讯”
android:textColor=”@color/yellow”
android:layout_alignParentBottom=”true”
/>
代码中
private TextView tv;
tv=(TextView) findViewById(R.id.tv);
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) tv.getLayoutParams();
layoutParams.bottomMargin=20;
tv.setLayoutParams(layoutParams);
RelativeLayout对应xml控件的父布局。
原文:http://www.cnblogs.com/lgy0069/p/5286655.html