android:windowSoftInputMode="stateHidden"
2.listview 去分割线
android:divider="#00000000"
3.Edittext去下划线android:background="@null"
4.checkbox 去默认样式
android:button="@null"
5.GridView去滚动条
android:scrollbars="none"
6.GridView 间隔
android:horizontalSpacing="5dp" .两列之间的间距
android:verticalSpacing="5dp" 两行之间的间距。
File Uri Path转化
File File = new File(path)path = file.getAbsolutePath();
Uri uri = Uri.parse(path);
Drawable ,Bitmap转化
Drawable —> Bitmap:
获取资源文件(Drawable)中的 Bitmap
Resources res = getResources();
Bitmap bmp = BitmapFactory.decodeResource(res, R.drawable.ic_logo);
或者
Resource res = gerResource();
Drawable drawable = res.getDrawable(id);//获取drawable
BitmapDrawable bd = (BitmapDrawable) drawable;
Bitmap bm = bd.getBitmap();
Drawable 转化成 Bitmap 的通用方法
public static Bitmap drawableToBitmap(Drawable drawable) {
Bitmap bitmap = Bitmap.createBitmap(
drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(),
drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
Canvas canvas = new Canvas(bitmap);
//canvas.setBitmap(bitmap);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
drawable.draw(canvas);
return bitmap;
}
Bitmap —> Drawable
Drawable drawable = new BitmapDrawable(bmp);
public static byte[] getBytes(Bitmap bitmap){
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
return baos.toByteArray();
}
byte[] —> Bitmap
public static Bitmap Bytes2Bimap(byte[] b) {if (b.length != 0) {
return BitmapFactory.decodeByteArray(b, 0, b.length);
} else {
return null;
}
}
fragment跳转
FmFragment fmFragment = (FmFragment) getParentFragment();
HomeActivity homeActivity = (HomeActivity) fmFragment.getActivity();
ViewPager homeVpager = (ViewPager) homeActivity.findViewById(R.id.vpager_home);
homeVpager.setCurrentItem(0);
RadioGroup radioGroupHome = (RadioGroup) homeActivity.findViewById(R.id.radiogroup_home);
radioGroupHome.check(R.id.radio1_home);
//宿主activity中的getTitles()方法
public String getTitles(){
return "hello";
}
//Fragment中的onAttach方法
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
titles = ((MainActivity) activity).getTitles();
}
//通过强转成宿主activity,就可以获取到传递过来的数据
Activity中添加fragment
<LinearLayout
android:id="@+id/top"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1">
</LinearLayout>
<LinearLayout
android:id="@+id/buttom"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1">
</LinearLayout>
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
//步骤二:用add()方法加上Fragment的对象
RegisterFragment registerFragment = new RegisterFragment();
LoginFragment loginFragment = new LoginFragment();
transaction.add(R.id.top, registerFragment);
transaction.add(R.id.buttom, loginFragment);
//步骤三:调用commit()方法使得FragmentTransaction实例的改变生效
transaction.commit();
html字体颜色
String str = item.getCount + "订阅" + "总帖数<font color = '#ff678d'>" + item.getOther() + "</font>"