Android 给CheckBox设置背景】的更多相关文章

一般来说我们给控件(Button,LinearLayout,ImageView,TextView等)设这背景的时候只需要设置这些控件的android:background即可, 但是在给CheckBox设置背景的时候这样设置就会出现背景图片偏大的问题. 怎么保证给CheckBox设置的背景大小正合适呢?请看如下代码: <CheckBox android:id="@+id/orderpay_cb_zhifubao" android:layout_width="wrap_c…
xml文件设置背景图片中:任意一个控件,button imageView 或layout,在其的xml属性设置中,添加 [XML] view plaincopy android:background="@drawable/bg" 即可实现设置其背景图片为bg. 图片存放在drawable目录下. drawable目录下存放大小图标共用的图片.drawable-hdpi中存放240 WVGA800 的模拟器或板子用的图片.drawable-mdpi存放对应的小图片 [XML] view…
//设置背景图片        String picfile= Environment.getExternalStorageDirectory() + "/pdp/pdp.png";        try {            Drawable d = Drawable.createFromPath(picfile);            linearLayout.setBackground(d);            //Toast.makeText(getApplicati…
点击按钮实现图片轮播效果 实践案例: xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="h…
变暗 WindowManager.LayoutParams lp=getWindow().getAttributes(); lp.alpha=0.3f; getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); getWindow().setAttributes(lp); 变为原来的样子 WindowManager.LayoutParams lp=getWindow().getAttributes(); lp.alpha=…
1.Button或者ImageButton的背景透明或者半透明 半透明:<Button android:background="#e0000000"···> 透明:<Button android:background="#00000000"···>   颜色和不透明度 (alpha) 值以十六进制表示法表示.任何一种颜色的值范围都是 0 到 255(00 到 ff).对于 alpha,00 表示完全透明,ff 表示完全不透明.表达式顺序是“a…
list_item.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent&q…
在给控件设置背景时像ps那样的背景透明 在3.0以下可以使用 imageView.setBackgroundResource(android.R.id.empty); 但是这个方法在3.0以上会出现 ERROR/AndroidRuntime(xxxxx): Caused by: android.content.res.Resources$NotFoundException: File  from drawable resource ID #0x1020004 可以用 imageview.setB…
一.图片预览:                  一.实现功能: 需求要实现布局中为圆形图片,图片背景与图标分开且合并到一个ImageView. 二.具体实现: XML中布局中定义ImageView,关健设置两个参数  Android:backgroup(设置背景),Android:src(设置ImageVIew中图片),圆形图片制作Drawable下定义xml shap样式(solid-color,size-width\hight) XML代码如下: <ImageView android:id…
一.设置图片背景 首先你先将一个的背景图片存入工程中res/drawble(当然drawble-hdpi.drawble-mdpi.drawble-ldpi中一个或者几个文件夹都可)文件夹中.假如我存入的图片名称为bj.png 第一种,在对应的布局文件(自动生成的工程默认文件是在res/layout中的main.xml)中的LinearLayout(默认)属性中添加android:background="@drawable/bj" 第二种,在你要添加背景的activity的类文件中se…