九,TextView
| includeFontPadding=false | includeFontPadding的设置,并不是我们想象的0间隙,只是去掉了一定的padding空间而已。 |
八,RelativeLayout
| android:layout_alignWithParentIfMissing = true | 如果对应的兄弟元素找不到的话就以父元素做参照物 |
七,
EditText不可编辑
setInputType(InputType.TYPE_NULL);
七,调试文本,调试可以看到文字
tools:text="123"
六,ediText 设置光标问题
普通设置 EditText 光标显示位置的方法就是
et.setSelection(text.length());
et.setSelection(0);
设置0 就是第一位了。 设置text长度就最后了。
如果还不行,那就
要先设置一下获取焦点 EditText.requestFocus()
再去设置selection
五,请求父级View不拦截touch事件
requestDisallowInterceptTouchEvent(true);
四,获取子View的大小的一种常用方式
mLlyConter.measure(0,0);
三,关于android:foreground设置无效的问题
case R.styleable.View_foreground:
if (targetSdkVersion >= VERSION_CODES.M || this instanceof FrameLayout) {
setForeground(a.getDrawable(attr));
}
break;
二,对EditText进行编辑完之后点击软键盘上的回车键或者搜索触发事件
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
if (search_et_ship_name?.text.toString().trim { it <= ' ' }.isNotEmpty()) {
search_et_ship_name?.clearFocus()
hideSoftInput()
}
return@setOnEditorActionListener true
}
false
一,对EditText设置把软键盘上的回车键改为搜索
<EditText
android:background="@null"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center_vertical"
android:hint="船名、港口"
android:imeOptions="actionSearch"
android:singleLine="true"
android:textColor="@color/text_color_666"
android:textColorHint="@color/text_color_hint"
android:textSize="14sp" /
本文分享了Android UI编程中的一些实用技巧,包括TextView、RelativeLayout布局调整、EditText编辑及光标控制、触摸事件处理等,帮助开发者提升用户体验。
1万+

被折叠的 条评论
为什么被折叠?



