在开发中往往要实现一些效果,在这里将会陆续整理。。。
1、TextView显示点点
android:ellipsize="end"
android:singleLine="true"
android:layout_width="120dp"
2、drawableRight、drawableLeft 代码设置图片、隐藏图片
// TextView使用代码设置drawableRight
public static void setdrawableRight(Context context, TextView textView,int idResource) {
Drawable drawable = context.getResources().getDrawable(idResource);
//这一步必须要做,否则不会显示.
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
textView.setCompoundDrawables(null, null, drawable, null);
}
// EditText使用代码设置drawableRight
public static void setdrawableRight(Context context, EditText editText, int idResource) {
Drawable drawable = context.getResources().getDrawable(idResource);
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
editText.setCompoundDrawables(null, null, drawable, null);
editText.setCompoundDrawablePadding(50);
}
//隐藏方法
tv_add_imgLibary.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);