Android小知识点总结

来源:互联网 发布:java 自然语言 编辑:程序博客网 时间:2024/06/02 04:58

1.AppIcon切图尺寸

drawable-xhdpi—-96 96
drawable-mdpi—–48
48
drawable-ldpi—–36 36
drawable-hdpi—–72
72

2.横竖屏切换想要不重新执行生命周期需配置

android:configChanges=”orientation|keyboardHidden|screenSize”
配置后只会执行onConfigurationChanged方法。

3.ListView子条目上有按钮优先级问题

可以在子布局根目录,也就是Item布局的根目录添加以下属性
android:descendantFocusability=”blocksDescendants”

4.ScrollView中套用ListView时直接跳转到ListView记录第一条位置

可以在父布局元素下添加以下属性
android:focusable="true"android:focusableInTouchMode="true"

5.页面背景变成黑色

尝试修改主题为
android:theme=”@android:style/Theme.Light.NoTitleBar”

6.弹出软键盘修改右下角按钮

imeOptions一共有4个属性值:

  1. actionUnspecified 未指定,对应常量EditorInfo.IME_ACTION_UNSPECIFIED.

  2. actionNone 没有动作,对应常量EditorInfo.IME_ACTION_NONE

  3. actionGo 去往,对应常量EditorInfo.IME_ACTION_GO

  4. actionSearch 搜索,对应常量EditorInfo.IME_ACTION_SEARCH

  5. actionSend 发送,对应常量EditorInfo.IME_ACTION_SEND

  6. actionNext 下一个,对应常量EditorInfo.IME_ACTION_NEXT

  7. actionDone 完成,对应常量EditorInfo.IME_ACTION_DONE

android:imeOptions="actionSearch" android:singleLine="true"


然后添加点击事件

view.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
// 点击搜索后隐藏键盘`
((InputMethodManager) title_searck.getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE))
.hideSoftInputFromWindow(getCurrentFocus()
.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
return true;
}
return false;
}
});

7.在String.xml中添加空格时用以下方式

 (后面的分号要带)






0 0