2019独角兽企业重金招聘Python工程师标准>>>
一:Android 弹软键盘时listview的变化控制:
问题描述:界面中有三部分,上面是标题栏,中间是Listview,下面是输入框。当点击输入框时,保持标题栏,挤压ListView。最终效果类似于微信聊天界面效果
设置一:在AndroidMnanifest.xml中相应的Activity加上android:windowSoftInputMode="adjustResize"
如果不想在一进界面就弹软键盘应该设置成android:windowSoftInputMode="adjustResize|stateHidden"
设置二:在布局文件中的ListView中加入android:transcriptMode="normal"
原文地址:http://www.xuebuyuan.com/2174446.html
二:android ListView 几个重要属性:
android:stackFromBottom="true"
功能等同于:mListView.setSelection(mListView.getCount() - 1);
原文地址:http://blog.csdn.net/avenleft/article/details/7334060
三:问题引出:
在TextView中有android:maxHeight=""可以限制最高是多少,可在LinearLayout或ListView中没有这个属性。如果我想在layout_height="wrap_content"的情况下限制LinearLayout或ListView的最高要怎么做,谢谢。
解决办法:
http://blog.lovelyhq.com/setting-listview-height-depending-on-the-items/
http://stackoverflow.com/questions/30036472/is-it-possible-to-set-listview-maxheight-in-xml
四:
public View getViewByPosition(int pos, ListView listView) {
final int firstListItemPosition = listView.getFirstVisiblePosition();
final int lastListItemPosition = firstListItemPosition + listView.getChildCount() - 1;
if (pos < firstListItemPosition || pos > lastListItemPosition ) {
return listView.getAdapter().getView(pos, null, listView);
} else {
final int childIndex = pos - firstListItemPosition;
return listView.getChildAt(childIndex);
}
}
五、ScrollView始终显示滚动条:
Android:scrollbars="vertical"
android:fadeScrollbars="false"
要两个参数都设置才能成功