谷歌Android开发常见错误及技巧
2011-01-21 15:44:49 来源:本站整理 闂傚倸鍊搁崐鎼佸磹閹间礁纾归柟闂寸绾惧綊鏌熼梻瀵割槮缁惧墽鎳撻—鍐偓锝庝簻椤掋垺銇勯幇顖毿撻柟渚垮妼椤粓宕卞Δ鈧獮濠勭磽閸屾艾鈧懓顫濋妸鈺佺疅缂佸顑欓崥瀣煕椤愵偅绶氱紓鍐╂礋濮婂宕掑▎鎴М濠电姭鍋撻梺顒€绉甸幆鐐哄箹濞n剙濡肩紒鎰殜閺屸€愁吋鎼粹€茬敖婵炴垶鎸哥粔鐢稿Φ閸曨垰鍐€妞ゆ劦婢€濞岊亪姊虹紒妯诲蔼闁稿海鏁诲濠氭晲婢跺﹤宓嗛梺缁樺姈缁佹挳宕戦幘璇叉嵍妞ゆ挻绋戞禍鐐叏濡厧浜鹃悗姘炬嫹

9、控件两端对齐:
如下代码让 位于同一行的两个控件分别左对齐和右对齐:
< RelativeLayout
xmlns:Android = "http://schemas.android.com/apk/res/android"
Android:background= "@drawable/top"
Android:layout_width= "fill_parent"
Android:layout_height= "wrap_content"
>< ImageView
Android:id = "@+file_browser/imgRefresh"
Android:layout_width= "wrap_content"
Android:layout_height= "wrap_content"
Android:layout_marginLeft= "10px"
Android:src = "@drawable/refresh"
Android:layout_centerVertical= "true"
>
</ ImageView>
< ImageView
Android:id = "@+file_browser/imgCheck"
Android:layout_alignParentRight= "true"
Android:layout_width= "wrap_content"
Android:layout_height= "wrap_content"
Android:layout_marginRight= "10px"
Android:src = "@drawable/close"
Android:layout_centerVertical= "true"
>
</ ImageView>
</ RelativeLayout>
10、android软键盘 把控件 往上挤的解决办法:
键盘区域外才是屏幕的边缘,定义布局文件时使用:android:gravity="bottom"的话就会被挤到上部!
解决办法:
在此工程的androidMainfest.xml文件中对应的Activity中写入 android:windowSoftInputMode="adjustPan"
或者在配置文件中把布局文件的大小写死!
11、在布局中使用scrollview:
把原来的布局用
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="none">括起来即可实现视图的滚动。
更多精彩
赞助商链接