附件:http://pan.baidu.com/s/1kTz9Y79
对照status_bar.xml该状态栏为仿flyme高状态栏布局,分析如下:
第5行跟24构成一个大控件
第7行跟23构成一个子控件,同时它又是其他控件的父控件。
第8行跟11构成一个子控件,
第12行跟22构成一个子控件,同时它又是其他控件的父控件。
第13行跟21构成一个子控件,同时它又是其他控件的父控件。
第16行跟19构成一个子控件。
接下来看id识控件:
第6行是时钟控件,所谓时间居左可以这样布局,当然还有其他方法布局。android:id="@id/clock"
第10行是运营商控件。可以要id可以不要
第14行是软件通知图标控件。android:id="@id/notificationIcons"
第15行是系统通知图标控件,如插入数据线显示的已连接USB的图标、gps定位图标等。android:id="@id/statusIcons"
第17行是信号控件android:id="@id/signal_cluster"
第18行是电池控件android:id="@id/battery"
第20行是耳机控件android:id="@id/headset"
仿flyme高状态栏布局重要代码有这些:
<com.android.systemui.statusbar.policy.Clock android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:textSize="35.0dip" android:gravity="left|center" android:id="@id/clock" android:paddingLeft="0.0dip" android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleLine="true" />
<LinearLayout android:orientation="vertical" android:paddingLeft="6.0dip" android:paddingRight="0.0dip" android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:gravity="right" android:paddingRight="0.0dip" android:layout_width="fill_parent" android:layout_height="0.0dip" android:layout_weight="1.0">
往这里加控件
</LinearLayout>
<LinearLayout android:paddingRight="0.0dip" android:layout_width="fill_parent" android:layout_height="0.0dip" android:layout_weight="1.0">
<LinearLayout android:gravity="right" android:layout_width="fill_parent" android:layout_height="fill_parent">
往这里加控件
</LinearLayout>
</LinearLayout>
</LinearLayout>
以上20行到29就是仿flyme高状态栏布局的一种源代码。来分析一下:
第19行是时间控件,这样就时间居左。
20行到29行指定线性布局,方向为垂直,控件是从上到下放置的,然后加上奇葩的21行android:layout_height="0.0dip" android:layout_weight="1.0">和24行android:layout_height="0.0dip" android:layout_weight="1.0">
这两个控件的比例为1:1,而本身高度为0,那么这两个控件就平分状态栏高度,就出现了分层现象了。懂了吧
另外framework-res\res\values\dimens.xml查找status_bar_height 找到 <dimen name="status_bar_height">40.0dip</dimen> 高度原来一般是24.0dip,把它改成40.0dip,状态栏变高了,40.0dip这个值自己决定,一般38.0dip以上.
教程结束。
对照status_bar.xml该状态栏为仿flyme高状态栏布局,分析如下:
第5行跟24构成一个大控件
第7行跟23构成一个子控件,同时它又是其他控件的父控件。
第8行跟11构成一个子控件,
第12行跟22构成一个子控件,同时它又是其他控件的父控件。
第13行跟21构成一个子控件,同时它又是其他控件的父控件。
第16行跟19构成一个子控件。
接下来看id识控件:
第6行是时钟控件,所谓时间居左可以这样布局,当然还有其他方法布局。android:id="@id/clock"
第10行是运营商控件。可以要id可以不要
第14行是软件通知图标控件。android:id="@id/notificationIcons"
第15行是系统通知图标控件,如插入数据线显示的已连接USB的图标、gps定位图标等。android:id="@id/statusIcons"
第17行是信号控件android:id="@id/signal_cluster"
第18行是电池控件android:id="@id/battery"
第20行是耳机控件android:id="@id/headset"
仿flyme高状态栏布局重要代码有这些:
<com.android.systemui.statusbar.policy.Clock android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:textSize="35.0dip" android:gravity="left|center" android:id="@id/clock" android:paddingLeft="0.0dip" android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleLine="true" />
<LinearLayout android:orientation="vertical" android:paddingLeft="6.0dip" android:paddingRight="0.0dip" android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:gravity="right" android:paddingRight="0.0dip" android:layout_width="fill_parent" android:layout_height="0.0dip" android:layout_weight="1.0">
往这里加控件
</LinearLayout>
<LinearLayout android:paddingRight="0.0dip" android:layout_width="fill_parent" android:layout_height="0.0dip" android:layout_weight="1.0">
<LinearLayout android:gravity="right" android:layout_width="fill_parent" android:layout_height="fill_parent">
往这里加控件
</LinearLayout>
</LinearLayout>
</LinearLayout>
以上20行到29就是仿flyme高状态栏布局的一种源代码。来分析一下:
第19行是时间控件,这样就时间居左。
20行到29行指定线性布局,方向为垂直,控件是从上到下放置的,然后加上奇葩的21行android:layout_height="0.0dip" android:layout_weight="1.0">和24行android:layout_height="0.0dip" android:layout_weight="1.0">
这两个控件的比例为1:1,而本身高度为0,那么这两个控件就平分状态栏高度,就出现了分层现象了。懂了吧
另外framework-res\res\values\dimens.xml查找status_bar_height 找到 <dimen name="status_bar_height">40.0dip</dimen> 高度原来一般是24.0dip,把它改成40.0dip,状态栏变高了,40.0dip这个值自己决定,一般38.0dip以上.
教程结束。