A015-佈局之LinearLayout good 巫山老妖php
Android UI開發: 橫向ListView(HorizontalListView)及一個簡單相冊的完整實現 (附源碼下載)html
ShapeDrawable和GradientDrawable的簡單使用java
一、咱們只有在button2使用了layout_weight屬性,並賦值爲1;可是button1和button2並無使用這個屬性,根據API能夠知道,他們的layout_weight屬性等於0。android
二、LinearLayout若是顯式包含layout_weight屬性時,會measure兩次;第一次將正常計算三個button的寬高,第二次將結合layout_weight的值分配剩餘的空間。git
通俗點來總結:Android系統先按照你設置的3個Button高度Layout_height=wrap_content,給你分配好他們3個的高度,而後會把剩下來的屏幕空間所有賦給Button2,由於只有他的權重值是1,這也是爲何Button2佔了那麼大的一塊空間。程序員
在layout_width設置爲match_parent的時候,layout_weight所表明的是你的控件要優先儘量的大,但這個大是有限度的,即match_parent。
在layout_width設置爲wrap_content的時候,layout_weight所表明的是你的控件要優先儘量的小,但這個大是有限度的,即wrap_content。github
android:layout_weight的真實含義是:一旦View設置了該屬性(假設有效的狀況下),那麼該 View的寬度等於原有寬度(android:layout_width)加上剩餘空間的佔比!ide
三個屬性都用來適應視圖的水平或垂直大小,一個以視圖的內容或尺寸爲基礎的佈局比精確地指定視圖範圍更加方便。佈局
1)fill_parentpost
設置一個構件的佈局爲fill_parent將強制性地使構件擴展,以填充佈局單元內儘量多的空間。這跟Windows控件的dockstyle屬性大致一致。設置一個頂部佈局或控件爲fill_parent將強制性讓它佈滿整個屏幕。
2) wrap_content
設置一個視圖的尺寸爲wrap_content將強制性地使視圖擴展以顯示所有內容。以TextView和ImageView控件爲例,設置爲wrap_content將完整顯示其內部的文本和圖像。佈局元素將根據內容更改大小。設置一個視圖的尺寸爲wrap_content大致等同於設置Windows控件的Autosize屬性爲True。
3)match_parent
Android2.2中match_parent和fill_parent是一個意思 .兩個參數意思同樣,match_parent更貼切,因而從2.2開始兩個詞均可以用。那麼若是考慮低版本的使用狀況你就須要用fill_parent了
android:scaleType="fitXY"
Android視圖繪製流程徹底解析,帶你一步步深刻了解View(二)
onMeasure()、onLayout()和onDraw()
Android自定義View(CustomCalendar-定製日曆控件)
Android:focusable="true"
android:focusableInTouchMode="true"
2.代碼中動態設置:
editText.setFocusable(true);//設置獲取焦點
但實際應用中setFocusable(true)方法失效!不知道什麼鬼。
後來查文檔,editTextview.requestFocus();//代碼動態設置焦點(實現)
findViewById在Activity和View中的區別 good
View contentView = getLayoutInflater().inflate(R.layout.popup, null);
Android ComboBox -- Spinner基礎使用
該控件主要實現方式爲Button 從寫 + PopupWindow ListView 組合
public Button(Context context, AttributeSet attrs) { this(context, attrs, com.android.internal.R.attr.buttonStyle); }
AS問題解決系列2—Resources中getDrawable(int)過期
xml 技巧
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#EFEFEF"/> <corners android:radius="3dip" /> <stroke android:width="0.5px" android:color="#505050"/> </shape> </item> </layer-list>
自定義鍵盤代碼
有時候咱們跳轉到某些頁面時,但願能立刻獲取特定TextView的焦點並彈出軟鍵盤
editText.setFocusable(true); editText.requestFocus(); InputMethodManager imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(0,InputMethodManager.HIDE_NOT_ALWAYS);