方法1 Drawable drawable= getResources().getDrawable(R.drawable.drawable); /// 这一步必须要做,否则不会显示. drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); myTextview.setCompoundDrawables(drawable,null,null,null); 方法2 public void s…
我们平常可以直接在xml里设置margin,如: <ImageView android:layout_margin="5dip" android:src="@drawable/image" /> 但是有些情况下,需要在java代码里来写,可是View本身没有setMargin方法,怎么办呢? 通过查阅android api,我们发现android.view.ViewGroup.MarginLayoutParams有个方法setMargins(left,…
textV.setTextColor(Color.parseColor("#FF0000")); <pre name="code" class="java">tv_price.setTextColor(getResources().getColor(R.color.img_all_text_color));…
转自:http://ghostfromheaven.iteye.com/blog/752181 Android 的实现TextView中文字链接的方式有很多种. 总结起来大概有4种: 1.当文字中出现URL.E-mail.电话号码等的时候,可以将TextView的android:autoLink属性设置为相应的的值,如果是所有的类型都出来就是android:autoLink="all".当然也可以在java代码里做,textView01.setAutoLinkMask(Linkify.…
习惯了直接在xml里设置margin(距离上下左右都是10dip),如: <ImageView android:layout_margin="10dip" android:src="@drawable/image" /> 只是有些情况下,需要在java代码里来写. API中,android.view.ViewGroup.MarginLayoutParams有个方法setMargins(left, top, right, bottom).可是View本身没…
========  3 在Java代码里设置button的margin(外边距)? 1.获取按钮的LayoutParams LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)button.getLayoutParams(); 2.在LayoutParams中设置margin layoutParams.setMargins(100,20,10,5);//4个参数按顺序分别是左上右下 3.把这个LayoutPara…
<style name="text_style"> <item name="android:textStyle">bold</item> <item name="android:textSize">18sp</item> </style>xml使用:<TextView style="@style/button_style"android:layout…
1.定义LayoutParams LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);//定义一个LayoutParams 2.在LayoutParams中设置marginLeft layoutParams.setMargins(20,0,0,0);//4个参数…
setTextSize(TypedValue.COMPLEX_UNIT_PX,22); //22像素 setTextSize(TypedValue.COMPLEX_UNIT_SP,22); //22SP setTextSize(TypedValue.COMPLEX_UNIT_DIP,22);//22DIP     平时用的少,动态设置时 使用 两个形参那个参数就行     如果,想要app中的字体不受 setting-->>字体-->>字体大小中的设置的影响 1.将字体大小定义在布…
比如:字符串a与字符串B对比,只需调用 a.equalsIgnoreCase(B);即可.很简单的一个方法.忽略大小写.…