zoukankan      html  css  js  c++  java
  • Android编程设置LayoutParams

     1         RelativeLayout.LayoutParams linearParams = (RelativeLayout.LayoutParams)viewHolder.headerWraper.getLayoutParams();
     2         RelativeLayout.LayoutParams textParams = (RelativeLayout.LayoutParams)viewHolder.textWrapper.getLayoutParams();
     3         
     4         linearParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0); //清空alignParentRight参数
     5         textParams.addRule(RelativeLayout.ALIGN_LEFT, 0);           //清空toLeftOf参数
     6         
     7         if (fromToType == Constants.FromToType.FromToTypeFromThisUser.getValue()) { //根据条件设置Layout参数
     8 
     9             linearParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    10             textParams.addRule(RelativeLayout.LEFT_OF, R.id.header_wrapper);
    11             
    12             viewHolder.headerWraper.setLayoutParams(linearParams);
    13             viewHolder.textWrapper.setLayoutParams(textParams);
    14             
    15             Logger.d(TAG, "from this user");
    16         }
    17         else{
    18             Logger.d(TAG, "from otehr user");
    19             
    20             linearParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    21             textParams.addRule(RelativeLayout.RIGHT_OF , R.id.header_wrapper);
    22             
    23             viewHolder.headerWraper.setLayoutParams(linearParams);
    24             viewHolder.textWrapper.setLayoutParams(textParams);
    25             
    26             viewHolder.textWrapper.setBackgroundResource(R.drawable.chat_other);
    27         }
  • 相关阅读:
    Jedis API操作Redis数据库
    Go开发环境安装与环境变量配置
    Java中使用md5进行hash运算
    oracle创建表空间、用户
    CentOS安装MySQL
    Go语言之快速排序
    软件包管理rpm和yum
    第十一节:configParse模块
    redis数据库
    tcpdump命令
  • 原文地址:https://www.cnblogs.com/sunshine-anycall/p/3562518.html
Copyright © 2011-2022 走看看