Android布局常见设置

1.Edittext 自动弹出软键盘 

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);


Bitmap —> byte[]
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 fragment 传递数据

//宿主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>


        //步骤一:添加一个FragmentTransaction的实例
        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>"
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值