项目笔记

本文只记录一些零散的小的知识点,并持续更新。

1、EditText默认不获取焦点(默认不弹出键盘),点击后再弹出键盘
//在EditText之前的一个控件设置
android:focusable="true"
android:focusableInTouchMode="true"
2、EditText 文字位置
EditText的gravity默认是center,如果是多行或者EditText的高度很大,字体是垂直居中的,如果想字体从左上角开始,请设置成android:gravity="top"
3、进入activity设置不弹出键盘
   <activity android:name=".ui.activity.OrderActivity"
            android:screenOrientation="landscape"
            android:windowSoftInputMode="stateHidden"/>
4、TextView设置不同大小颜色
//style.xml里面
<style name="style0">
    <item name="android:textSize">26pt</item>
    <item name="android:textColor">@color/black_1</item>
</style>

<style name="style1">
    <item name="android:textSize">22pt</item>
    <item name="android:textColor">@color/gray_4</item>
</style>


//使用
Spannable sp = new SpannableString("退货原因(选填)") ;
sp.setSpan(new TextAppearanceSpan(getContext(), R.style.style0),0,4,Spannable.SPAN_INCLUSIVE_INCLUSIVE);
sp.setSpan(new TextAppearanceSpan(getContext(), R.style.style1),4,8,Spannable.SPAN_INCLUSIVE_INCLUSIVE);
tvTag.setText(sp);
5、recycleView去掉上下滑动时的阴影
android:overScrollMode="never"
6、git错误:Warning:not allowed to load local resourece to an error:bad signature fatal:index file corrupt
进入项目目录下,.git同级,打开cmd
rm -f .git/index
git reset
重启AndroidStudio
7、EditTex点击也不弹出键盘
//禁止光标,禁止弹出键盘
etContent.setInputType(InputType.TYPE_NULL);
8、ScrollView去掉上下拉时的阴影
android:overScrollMode="never"
9、EditText弹出键盘变搜索
android:imeOptions="actionSearch"
android:singleLine="true"


editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                getOrderList(editText.getText().toString().trim()
                        , cashierId, orderType, payType, orderState, startTime, endTime);
                hideKeyboard(editText);
                return true;
            }
            return false;
        }
    });


public void hideKeyboard(View view) {
    InputMethodManager manager = (InputMethodManager) view.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    manager.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

10、EditText修改光标颜色
 android:textCursorDrawable="@drawable/my_cursor"


<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <solid android:color="@color/blue_1"/>
    <size android:width="2pt"/>
</shape>
11、商米收银机

T2系列,usb连接和扫码枪同时连接会出问题。扫码枪会无法使用,断开usb过程可能activity会销毁重建。

android:configChanges="navigation|keyboardHidden|keyboard"
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值