1. 程式人生 > >Andriod Studio下做第一個demo,結構分析

Andriod Studio下做第一個demo,結構分析

一. 主要檔案:      AndroidMainfest.xml全域性配置檔案,寫了哪個java類檔案需要註冊進去     <activity android:name=".MainActivity">  //包名加類名                      </activity>      期間可以加<intent-filter>                 <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />             </intent-filter>便使該java類成為啟動時第一個類         

  activity_main.xml:控制元件樣式檔案      mainactivity.java:寫java程式碼

   res:資料夾下的主要檔案:        drawable:單控制元件的樣式檔案,圖片等        layout:介面佈局檔案        values:資原始檔,如顏色字型等

二.基本用的佈局     1.線性佈局 LinearLayout  2. 相對佈局 relativelayout      LineatLayout常用的屬性: android:id                     佈局的id                          android:layout_margin     佈局的寬度                          android:layout_height      佈局的高度                          android:layout_margin     佈局的外邊距             (match_parent根據父級佈局取,wrap_content根據內容取)幾個屬性都是通用於其他標籤                          android:layout_padding   佈局的內邊距                          android:background        佈局的背景                          android:orientation          佈局的方向 ve:豎向  ho:橫向      2.相對佈局更多的屬性:android:Layout_toleft   在誰的左邊                                         android:Layout_toright  在誰的右邊                                         android:Layout_below   在誰的下面                                         android:Layout_toleft      3.大小,佈局長寬使用dp,字型使用sp 三.樣式     TextView:    textcolor   textsize   maxline(最大行數,一旦文字超過這些行則不顯示)                             ellipsize=“end”(這樣會讓不顯示的文字顯示點點點)                             ellipsize=“marquee” 跑馬燈         跑馬燈示例:必須強調的幾個屬性              android:ellipsize="marquee"   //設定為格式跑馬燈              android:marqueeRepeatLimit="marquee_forever"  //跑馬燈迴圈次數              android:singleLine="true"   //唯一行數,目前已被禁用,不夠必須設定              android:focusable="true"                android:focusableInTouchMode="true"  

                         drawbleright(右邊放一個什麼)                                                    Button:更改button樣式                      1.在drawable右鍵 drawable resource file   第二行選擇shape,用來寫button的樣式                            <shape>標籤裡寫形狀與樣式                       如果要使用按壓效果之類的按鈕效果,則新建檔案屬性為selector,將不同狀態下的樣式做更改即可實現                    2.常用屬性:填充顏色(可以用背景顏色)<solid android:color="#FF3E96"></solid>                                       角的弧度<corners android:radius="30sp"></corners>