/** * 隐藏软件盘 * @param input */ private void hideSoftKeyboard(EditText input){ //输入方法管理器 InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); //隐藏指定控件引发的软件盘 inputMethodManager.hideSoftInputFromWindow(input.getWindowToken(),0); }
/** * 设置文本方向 * @param textview * @param text * @param align Layout.Alignment.ALIGN_NORMAL 默认左边,Layout.Alignment.ALIGN_OPPOSITE 右边,Layout.Alignment.ALIGN_CENTER 中间 */ private void appendText(TextView textview, CharSequence text, Layout.Alignment align){ if(text==null||text.toString().trim().length()==0){ return; } //字体位置span AlignmentSpan alignmentSpan = new AlignmentSpan.Standard(align); //字符串转span字符串 SpannableString spannableString = new SpannableString(text); //指定字符串位置改变, // Spannable.SPAN_EXCLUSIVE_EXCLUSIVE 相当于【】, // Spannable.SPAN_EXCLUSIVE_INCLUSIVE 相当于【), // Spannable.SPAN_INCLUSIVE_INCLUSIVE 相当于(), // Spannable.SPAN_INCLUSIVE_EXCLUSIVE 相当于(】 spannableString.setSpan(alignmentSpan,0,text.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE); if(textview.length() > 0){ textview.append("\n\n"); } textview.append(spannableString); }
//滚动底部 scrollView.fullScroll(View.FOCUS_DOWN); //滚动顶部 scrollView.fullScroll(View.FOCUS_UP);