首页 > 移动平台 > 详细

android中动态的设置距left,right,top,bottom

时间:2016-03-17 12:44:59      阅读:387      评论:0      收藏:0      [点我收藏+]

布局对应的xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
>
      <TextView
       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"
     />
</RelativeLayout>

 

代码中

   private   TextView     tv;

   tv=(TextView) findViewById(R.id.tv);
   RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) tv.getLayoutParams();
   layoutParams.bottomMargin=20;
   tv.setLayoutParams(layoutParams);

   RelativeLayout对应xml控件的父布局。

 

android中动态的设置距left,right,top,bottom

原文:http://www.cnblogs.com/lgy0069/p/5286655.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!