SJ64 1B&PS1

1B:
將不同的views組合在一起,稱之為viewgroups。
講了兩個布局:
LinearLayout
RelativeLayout
以及
內邊距padding和外邊距margin的效果及區別。
此次學習 主要是更加深了對這些基礎的認識。

最后關于采訪那段感覺還有挺有收獲的:
模塊化開發?(可以經常地復用 提高開發效率。
布局只是開始 布局之后還有各種處理 網絡訪問 數據儲存等。
還有布局設計不需要大材小用 比如一些布局可以用簡單的LinearLayout實現 就不建議用功能強大而復雜的RelativeLayout實現。
(1B)

PS1:

最后是一個生日賀卡app,再簡單也要自己動手實踐:

<?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

看見標題欄不太美觀:
于是在BirthdayActivity的setContentView方法前添加了:

requestWindowFeature(Window.FEATURE_NO_TITLE);

但出現:

Paste_Image.png

查找 發現有三種解決辦法:
1.如果繼承的是ActionBarActivity或者是AppCompatActivity就會報錯。如果你執意要用這個方法,則改為繼承Activity。
2.改用supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
3.在清單文件里改theme

最后采用了第二種方法:效果如圖:

Screenshot_2016-04-19-14-50-49.png

(PS1 Done)

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容