Android的一些布局小知识点
生活随笔
收集整理的這篇文章主要介紹了
Android的一些布局小知识点
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.布局的背景可以引入一個layout-list.xml代表設置變換的圖片,布局上面 中間 結束的顏色不同
1 <?xml version="1.0" encoding="utf-8"?> 2 <layer-list 3 xmlns:android="http://schemas.android.com/apk/res/android"> 4 <item> 5 <shape> 6 <gradient 7 android:startColor="#ffa6a6a6" 8 android:centerColor="#ffdbdbdb" 9 android:endColor="#ffe7e7e7" 10 android:height="1px" 11 android:angle="90" 12 android:dither="true" /> 13 </shape> 14 </item> 15 </layer-list>2.在TextView里面可以引入shadowDx,shadowDy,shadowColor來設置陰影
1 <TextView 2 android:layout_width="wrap_content" 3 android:layout_height="wrap_content" 4 android:layout_marginTop="20dip" 5 android:gravity="bottom" 6 android:shadowColor="#FFFFFF" 7 <!--水平方向的投影--> 8 android:shadowDx="0" 9 android:shadowDy="2" 10 android:shadowRadius="1" 11 android:text="@string/app_name" 12 android:textColor="#444444" 13 android:textSize="35dip" 14 android:typeface="serif" > 15 </TextView>3??如果要去掉標題欄一種在是代碼中寫一種是在布局文件中添加
?布局文件:android:theme="@android:style/Theme.NoTitleBar"
4.獲取版本號:獲取應用程序版本號
5.判斷手機是否有網絡連接
1 private boolean isNetWorkAvaiable(){ 2 //系統里面提供的網絡訪問狀況相關的服務 3 ConnectivityManager cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE); 4 5 NetworkInfo info =cm.getActiveNetworkInfo(); 6 7 if(info!=null){ 8 return info.isAvailable(); 9 }else{ 10 return false; 11 } 12 }
6.TabHost的顏色選擇器
7.如果一個應用程序有大量的相同的類似的布局。布局我們可以抽取出來
merge:代表當前布局可以被別的布局直接引用。
include:代表引用一個別的布局
但采用這種方法會降低系統的效率
8.設置ListView的間隔線條
1 divider="color/transparent" //間隔線條為透明 2 dividerHeight="5.0dip" //為5個dip 3 listSelector="" //設置點中時顏色 4 5 代碼設置分隔符 setDivider(new ColorDrawable(Color.TRANS)); 6 7 //第一個參數context 第二個參數引入的布局 第三個參數 需要設置的內容的ID,第四個參數對應需要設置的內容 8 lv.setAdapter(new ArrayAdapter<String>(this,R.layout.fav_item,R.id.fav_title,strs));?
?
?
?
轉載于:https://www.cnblogs.com/developer-wang/archive/2013/01/23/2873801.html
總結
以上是生活随笔為你收集整理的Android的一些布局小知识点的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 光影画教案一等奖
- 下一篇: Android---- 获取当前应用的