一:Android 彈軟鍵盤時listview的變化控制:html
問題描述:界面中有三部分,上面是標題欄,中間是Listview,下面是輸入框。當點擊輸入框時,保持標題欄,擠壓ListView。最終效果相似於微信聊天界面效果android
設置一:在AndroidMnanifest.xml中相應的Activity加上android:windowSoftInputMode="adjustResize"微信
若是不想在一進界面就彈軟鍵盤應該設置成android:windowSoftInputMode="adjustResize|stateHidden"佈局
設置二:在佈局文件中的ListView中加入android:transcriptMode="normal"spa
原文地址:http://www.xuebuyuan.com/2174446.html .net
二:android ListView 幾個重要屬性:code
android:stackFromBottom="true" orm
功能等同於:mListView.setSelection(mListView.getCount() - 1);xml
原文地址:http://blog.csdn.net/avenleft/article/details/7334060 htm
三:問題引出:
在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); } }
Android:scrollbars="vertical"
android:fadeScrollbars="false"
要兩個參數都設置才能成功