小知识点

来源:互联网 发布:夏威夷果 知乎 编辑:程序博客网 时间:2024/05/21 17:19

设置宽高自适配父窗体

img.setLayoutParams(newViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT));

 

params=newLinearLayout.LayoutParams(20,5);

params.setMargins(0,2,0,0);

params.leftMargin=10;

iv.setLayoutParams(params);

 

 

 

TextView过长显示省略号, TextView文字中间加横线

 

 

 

1.TextView显示的内容过长时自动显示省略号:

 

省略号的位置:

android:ellipsize="end"   省略号在结尾

android:ellipsize="start"  省略号在开头

android:ellipsize="middle"   省略号在中间

TextView显示的行数:

android:singleline="true"

android:lines="2"

 

 

在java文件中:

tv.setEllipsize(TextUtils.TruncateAt.valueOf("END"));

tv.setSingleLine(true);

tv.setEllipsize(null);// 展开

tv.setEllipsize(TextUtils.TruncateAt.END);// 收缩

 

2.TextView文字中间加横线:

tv_goods_price =(TextView) v.findViewById(R.id.tv_goods_price);

tv_goods_price.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);

底部加横线:

tv_goods_price.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);






MotionEvent.ACTION_CANCEL 当用户保持按下操作,并从你的控件转移到外层控件时,会触发ACTION_CANCEL

 

Shape 定义圆角 corners

SCROLL_STATE_IDLE  滑动空闲状态

SCROLL_STATE_FLING  惯性滑动状态

SCROLL_STATE_TOUCH_SCROLL  触摸滑动状态

 

java中有三种移位运算符

<<     :     左移运算符,num << 1,相当于num乘以2

>>     :     右移运算符,num >> 1,相当于num除以2

>>>   :     无符号右移,忽略符号位,空位都以0补齐

 

MeasureSpec.AT_MOST是子布局可以根据自己的大小选择任意大小的模式

 


activity向fragment中传值   

1。要传的值 放到Bundle对象里

 

2。通过创建传递封Fragment将bundle对象 通过 setArguments()传递到fragment

 

3.Fragment中 通过getArguments() 得到 bundle对象 就能得到里面的值

 

 

  •   Fragment1 fragment1 = new Fragment1();  
  •             Bundle bundle = new Bundle();  
  •             String strValue = et1.getText().toString().trim();  
  •             bundle.putString("str", strValue);  
  •             fragment1.setArguments(bundle);  
  •             //如果transaction  commit()过  那么我们要重新得到transaction  
  •             transaction = manager.beginTransaction();  
  •             transaction.replace(R.id.contents, fragment1);  
  •             transaction.commit();  

>

 

   Bundle bundle = getArguments();//activity传过来的Bundle  


除得两位小数,保留两位小数

privateStringnumConversion(intsales_volume){

DecimalFormatdf=newDecimalFormat("0.00");

doublei=(double)sales_volume/10000;

if(i>=1){

returndf.format(i)+"";

}

returnsales_volume+"";

}





0 0
原创粉丝点击