您的位置:首页 > 移动开发 > Android开发

Android小知识点总结

2016-08-01 17:17 176 查看
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.页面背景变成黑色


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


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



imeOptions一共有4个属性值:

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

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

actionGo 去往,对应常量EditorInfo.IME_ACTION_GO

actionSearch 搜索,对应常量EditorInfo.IME_ACTION_SEARCH

actionSend 发送,对应常量EditorInfo.IME_ACTION_SEND

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

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中添加空格时用以下方式

 ;(后面的分号要带)




内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: