1B:
將不同的views組合在一起,稱之為viewgroups式曲。
講了兩個布局:
LinearLayout
RelativeLayout
以及
內(nèi)邊距padding和外邊距margin的效果及區(qū)別吝羞。
此次學(xué)習(xí) 主要是更加深了對這些基礎(chǔ)的認(rèn)識恨溜。
最后關(guān)于采訪那段感覺還有挺有收獲的:
模塊化開發(fā)柏腻?(可以經(jīng)常地復(fù)用 提高開發(fā)效率。
布局只是開始 布局之后還有各種處理 網(wǎng)絡(luò)訪問 數(shù)據(jù)儲存等。
還有布局設(shè)計不需要大材小用 比如一些布局可以用簡單的LinearLayout實(shí)現(xiàn) 就不建議用功能強(qiáng)大而復(fù)雜的RelativeLayout實(shí)現(xiàn)。
(1B)
PS1:
最后是一個生日賀卡app,再簡單也要自己動手實(shí)踐:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/happybirthday"
android:scaleType="centerCrop"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="38sp"
android:fontFamily="sans-serif-light"
android:text="Hello Birthday, Ga!"
android:textColor="@android:color/white"
android:padding="16dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="From flyntsyc."
android:textSize="24sp"
android:textColor="@android:color/white"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="16dp"/>
</RelativeLayout>
效果圖:
Screenshot_2016-04-19-00-00-02.png
看見標(biāo)題欄不太美觀:
于是在BirthdayActivity的setContentView方法前添加了:
requestWindowFeature(Window.FEATURE_NO_TITLE);
但出現(xiàn):
Paste_Image.png
查找 發(fā)現(xiàn)有三種解決辦法:
1.如果繼承的是ActionBarActivity或者是AppCompatActivity就會報錯。如果你執(zhí)意要用這個方法贝润,則改為繼承Activity。
2.改用
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
3.在清單文件里改theme
最后采用了第二種方法:效果如圖:
Screenshot_2016-04-19-14-50-49.png
(PS1 Done)