發表文章

目前顯示的是 7月, 2017的文章

This view is not constrained - Android studio

To  quickly  resolve this, use this very helpful shortcut in Android Studio: Right-click widget-in-question > Constraint Layout > Infer Constraints: 教學連結 youto教學連結

android studio i18n hardcoded string textview should use @string resource

錯誤訊息 android studio [i18n] hardcoded string textview should use @string resource 雖然可以正常運行,但是這不是一個好習慣,應該在res/values/strings.xml中設置: youto教學連結

認識RelativeLayout

以父容器元件為相對位置的設定是使用true和false來設定。RelativeLayout版面配置設定為true或false的屬性整理於下表: android:layout_centerHorizontal 將子元件對齊於父元件橫向中間的位置 android:layout_centerVertical 將子元件對齊於父元件縱向中間的位置 android:layout_centerInParent 將子元件對齊於父元件中央的位置 android:layout_alignParentBottom 將子元件與父元件底部對齊 android:layout_alignParentLeft 將子元件與父元件左側對齊 android:layout_alignParentRight 將子元件與父元件右側對齊 android:layout_alignParentTop 將子元件與父元件上緣對齊

TextView常用屬性

屬性名稱 對應的XML程式碼 說明 height android:layout_height 設定文字的高度,單位dp。fill_parent和match_parent高度依文字高度自動調整。 width android:layout_width 設定文字的寬度,單位為dp。fill_parent和match_parent相同,都南填滿整個外框、wrap_content寬度依文字寬度自動調整。 text android:text 說定顯示的文字內容。 id android:id 設定元件的名稱。 textColor android:textColor 設定文字的顏色。顏色以「#RGB」格式表示,「#」後面接著以6個16進位的數字,每兩碼分別代表「紅」「綠」「藍」。例如:#FF0000為紅色。 textSize android:textSize 設定文字的大小,單位為sp。

EditText常用屬性

屬性名稱 對應的XML程式碼 說明 lines android:lines 設定最多可以顯的列數 ems android:ems 設定每列的字元數目,必須是width屬性設定為wrap_content,此屬性才有作用。 editable android:editable 是否可輸入文字 enabled android:enabled 設定是否作用 single line singleline false表示可輸入多列,true只能輸入一列 inputType android:inputType 這是一個相當重要的屬性,可以限定輸入資料的類型 text 可輸入所有字元 textUri 可輸入網址 textEmailAddress 可輸入電子郵件 textPassword 可輸入密碼 number 可輸入0~9的數字 date 可輸入日期(0~9、「/」) time 可輸入日期(0~9、「:pam」) phone 可輸入電話號碼 numberSigned 可輸入帶負數符號的數字 numberDecimal 可輸入帶小數點的數字 unmberPassword 可輸入數字密碼 也可使用「|」設定同時核選多項輸入的格式 hint adnroid:hint 當輸入欄位為空時顯示的提示訊息