
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.获取版本号:获取应用程序版本号
1 private String getVersion() {
2 try {
3 PackageInfo info = getPackageManager().getPackageInfo(
4 getPackageName(), 0);
5 return info.versionName;
6
7 } catch (Exception e) {
8 e.printStackTrace();
9 // 包名没有找到的异常是不会发生的 通常会加一个 can't reach10 return null;
11 }
12
13 }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的颜色选择器
1 <selector xmlns:android="http://schemas.android.com/apk/res/android">
2 //被选中的时候 没有被选中的时候3 <item android:drawable="@drawable/tab_main_nav_on" android:state_selected="true"/>
4 <item android:drawable="@drawable/tab_main_nav_off" android:state_selected="false"/>
5
6 </selector>7.如果一个应用程序有大量的相同的类似的布局。布局我们可以抽取出来
merge:代表当前布局可以被别的布局直接引用。
include:代表引用一个别的布局
但采用这种方法会降低系统的效率
8.设置ListView的间隔线条
1 divider="color/transparent" //间隔线条为透明2 dividerHeight="5.0dip" //为5个dip3 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));