[Request] Could ANY/ALL Themers please take a look at this... - Android Themes

Hey guys, I was wondering if someone could help me out with something... I am a "developer" over in the Samsung Continuum thread, and I am on the verge of a breakthrough. (Background info for Samsung Continuum: Samsung Page: we are on Froyo 2.2.2...) I made it so the ticker could rotate depending on what orientation your phone is in (which wasn't included in stock). However, I am having difficulties in modifying the default portrait layout so that it is forced to show landscape.. Obviously things will have to be split up/shrunk, because we are working with a 480x96 pixel area. If you are still reading and are interested in helping a poor, stuck soul out, here are some details!
The Ticker "Main" layout screen is located within "framework-res.apk," while the background stuff happens in "services.jar." We do not have the source. I added code to services.jar to get it to rotate (by adding a WindowManger binder to the Ticker Screen). The code for the layout is here:
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_gravity="bottom" android:orientation="horizontal" android:id="@id/standbymode_default_vertical" android:background="@null" android:layout_width="fill_parent" android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout android:layout_gravity="top|left|center" android:id="@id/RelativeLayout01" android:layout_width="103.0px" android:layout_height="96.0px">
<ImageView android:layout_gravity="top" android:id="@id/WeatherIcon" android:layout_width="80.0px" android:layout_height="80.0px" android:layout_marginLeft="8.0px" android:layout_marginTop="8.0px" />
<ImageView android:id="@id/IconSel" android:background="@drawable/weather_press" android:visibility="gone" android:layout_width="80.0px" android:layout_height="80.0px" android:layout_marginLeft="8.0px" android:layout_marginTop="8.0px" android:layout_marginBottom="8.0px" />
</RelativeLayout>
<LinearLayout android:orientation="vertical" android:id="@id/LinearLayout02" android:layout_width="0.0dip" android:layout_height="96.0px" android:layout_weight="1.0">
<TextView android:textSize="@dimen/data.text.size" android:textStyle="bold" android:textColor="#ffffffff" android:layout_gravity="top|left|center" android:id="@id/TextView02" android:layout_width="wrap_content" android:layout_height="@dimen/data.layout.height" android:layout_marginTop="@dimen/data.layout.margin.top" android:layout_marginBottom="@dimen/data.layout.margin.bottom" />
<LinearLayout android:gravity="top" android:layout_width="fill_parent" android:layout_height="fill_parent">
<TextView android:textSize="@dimen/time.text.size" android:typeface="normal" android:textColor="@color/clockcolor" android:layout_gravity="top|left|center" android:id="@id/TextView03" android:layout_width="wrap_content" android:layout_height="@dimen/time.layout.height" android:layout_marginBottom="@dimen/time.layout.margin.bottom" />
<TextView android:textSize="@dimen/data.text.size" android:typeface="normal" android:textColor="@color/clockcolor" android:layout_gravity="top|left|center" android:id="@id/TextView04" android:paddingLeft="5.0px" android:layout_width="wrap_content" android:layout_height="@dimen/time.layout.height" android:layout_marginBottom="@dimen/time.layout.margin.bottom" />
</LinearLayout>
</LinearLayout>
<RelativeLayout android:id="@id/RelativeLayout02" android:layout_width="68.0px" android:layout_height="wrap_content">
<ImageButton android:id="@id/HistoryButton" android:background="@null" android:focusable="true" android:layout_width="68.0px" android:layout_height="wrap_content" android:src="@drawable/tt_tickerhistory_buttonup" android:scaleType="fitXY" android:layout_alignParentRight="true" />
</RelativeLayout>
</LinearLayout>
I need to make it so that ^^^ is forced into a landscape view...
Here are some pictures:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Thanks again to anyone who will take a look! If you need anything, just let me know!!!

Related

Widgetlocker XML Editing

Code:
<?xml version="1.0" encoding="UTF-8"?>
<FrameLayout android:gravity="center_horizontal" android:id="@id/sense_slider" android:background="@drawable/sense_slider" android:layout_width="320.0dip" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res/com.teslacoilsw.widgetlocker">
<com.teslacoilsw.widgetlocker.SenseDigitalClock android:gravity="center_horizontal" android:layout_gravity="center_horizontal" android:id="@id/time" android:paddingTop="22.0dip" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true">
<FrameLayout android:id="@id/clock" android:layout_width="fill_parent" android:layout_height="fill_parent">
<TextView android:textSize="48.0dip" android:typeface="sans" android:textColor="@android:color/white" android:gravity="center" android:id="@id/timeDisplay" android:layout_width="320.0dip" android:layout_height="wrap_content" android:shadowColor="@android:color/black" android:shadowDx="1.1" android:shadowDy="1.1" android:shadowRadius="1.2" />
<TextView android:textAppearance="?android:textAppearanceMedium" android:textSize="14.0dip" android:typeface="serif" android:textColor="@android:color/white" android:ellipsize="none" android:id="@id/am_pm" android:paddingLeft="206.0dip" android:paddingTop="35.0dip" android:layout_width="320.0dip" android:layout_height="wrap_content" android:singleLine="true" />
</FrameLayout>
<TextView android:textSize="14.0dip" android:textColor="@android:color/white" android:gravity="center_horizontal" android:layout_gravity="center_horizontal" android:id="@id/date" android:layout_width="wrap_content" android:layout_height="wrap_content" android:shadowColor="@android:color/black" android:shadowDx="1.1" android:shadowDy="1.1" android:shadowRadius="1.2" android:layout_below="@id/clock" android:layout_centerHorizontal="true" />
</com.teslacoilsw.widgetlocker.SenseDigitalClock>
</FrameLayout>
This is the XML For the Sense Widget In widgetlocker.
I want to edit it so there is no text, just image, that slides down.
Any help?
you could make the text color transparent, or text size 0

(08-15)Noobs guide to changing the Status bar font color

I was having a very difficult finding any information on how to modify the font color in the status bar so I decided it would be best to document it...here on xda.
What's covered in this thread:
How to edit the font color on the status bar.
How to make the status bar transparent
Credit:
Gruesomewolf For giving me the initial instructions on how to make background and status bar transparent.
JsChiSurf For guiding me through what I was doing wrong in order to make the status bar transparent.
xml items to modify the font in the status bar
Located in SystemUI.apk
layout>status_bar_expanded.xml
*This changes the Gingeritis 3D BETA VII font color and font size (Or Sprint if EVO)
<TextView android:textAppearance="@style/TextAppearance.StatusBar.Title" android:textSize="21.0px" android:textColor="#ff58aad0"
For EVO/EVO 3D the line code is:
<com.htc.widget.HtcBlinkingTextView android:textAppearance="?android:textAppearanceLarge" android:textSize="@dimen/status_bar_title_font_size" android:textColor="#ff58AAD0"
For the EVO/EVO 3D Clear button:
<TextView android:textSize="@dimen/clear_button_font_size" android:textColor="#ff58aad0"
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
layout>quick_settings.xml
*To change the color of the quick setting font color in the status bar
<TextView android:textAppearance="@style/TextAppearance.StatusBar.Title" android:textSize="21.0px" android:textColor="#ff58aad0"
values>Drawables
*To change the color of the Status bar Nofication Font
item type="drawable" name="APKTOOL_DUMMY_015c">false</item>
<item type="drawable" name="shade_bgcolor">#ff282828</item>
<item type="drawable" name="notification_header_text_color">#ff58aad0</item> <<<<----This changes the Text, "Notification seen in the top of the status bar while under Notifications
<item type="drawable" name="notification_number_text_color">#ff000000</item> <<Change back to white
<item type="drawable" name="list_item_background">#ffffffff</item>
<item type="drawable" name="list_item_background_gray">#fff2f2f2</item>
values>Colors
*Changes the primary and secondary status bar font color
<color name="white">#ff58aad0</color> <<<<<----This changes what the font color is when pressed on the status bar
<color name="black">#ff000000</color>
<color name="half_white">#7fffffff</color>
<color name="half_black">#7f000000</color>
<color name="primary_text_color">#ffffffff</color> <<<<---Primary Font Color
<color name="secondary_text_color">#ff000000</color> <<<<----Secondary Font Color
values>styles
*Changes the status bar font from bold to normal (What says Ginergitis 3D V1.0/Sprint) If you don't want it bold. It looks better bolded
*It also changes the bold appearance of the secondary font. They both look better bolded
<style name="TextAppearance.StatusBar.Title" parent="@android:style/TextAppearance.StatusBar">
<item name="android:textAppearance">?android:textAppearanceSmall</item>
<item name="android:textSize">15.0sp</item>
<item name="android:textStyle">bold</item> <<<<-----change to normal for none bold font
<item name="android:textColor">@drawable/notification_header_text_color</item>
End Result of changing colors
As I learn more about the status bar, I'll be updating this thread.
How to make the status bar transparent
Decompile the SystemUI.apk, the smali edits to enable transparency are as fallows
Open up "StatusBarService.smali", located in /smali/com/android/systemui/statusbar/"
Look for this line:
Code:
.line 504 .local v7, view:Lcom/android/systemui/statusbar/StatusBarView;
Directly below that are these lines:
Code:
const/4 v1, 0x2
iput v1, p0, Lcom/android/systemui/statusbar/StatusBarService;->mPixelFormat:I
.line 506
Delete those lines
Several lines below that you should find this line:
Code:
iget v5, p0, Lcom/android/systemui/statusbar/StatusBarService;->mPixelFormat:I
Change that to this
Code:
const/4 v5, -0x3
Next find this line:
Code:
.line 1731
const/4 v5, 0x2
Change it to: (note this line should be under .method onBarViewAttached()V)
Code:
.line 1731
const/4 v5, -0x3
Smali editing is complete!
Then we have to do some xml editing!
Look for "status_bar_tracking.xml", found in /res/layout <<<<Should be status_bar_expanded.xml
Line:
Code:
<View android:id="@id/background" android:background="@drawable/list_item_background"
change to:
Code:
<View android:background="@drawable/status_bar_background"
After find this line:
Code:
<View android:id="@id/tab_header" android:background="@drawable/list_item_background"
and again change to this
Code:
<View android:background="@drawable/status_bar_background"
Done!! Recompile .apk
Im sure by now you can see that we will now be able to simply make the .png named status_bar_backround transparent and thats that! Hope this helps!
EDIT:
status_bar_expanded.xml is what you need to edit. BTW, you do not reference the .9 when referencing .pngs. The system handles this automatically.
The background is hard coded in status_bar_expanded, and you have to re-arrange things.
list_item_background is what controls the default background / color for the notifications. It is fixed to a color. You can change the color, or even change it to point to an image if you want, such as the image you are attempting to modify, or assign it a full transparency if you don't want an image in the background, but rather, just for it to be clear, "#00000000".
Change the Quick Settings status bar to Transparent
Open up quick_setttings.xml found in res/layout/
Look for this line:
Code:
<LinearLayout android:orientation="vertical" android:background="@drawable/list_item_background" android:layout_width="fill_parent" android:layout_height="wrap_content">
Change "list_item_background to status_bar_background
It should look like this:
Code:
<LinearLayout android:orientation="vertical" android:background="@drawable/status_bar_background" android:layout_width="fill_parent" android:layout_height="wrap_content">
FAQ
Q:I placed @drawable/status_bar_background to anyplace it said @drawable/list_item_background.
However, my transparent png is located in SystemUI.apk/drawable-hdpi. Will the system still find it even though the code says, "drawable?"
A: Your close. It all depends on how your XML is laid out as it relates to parents / children, and their respective backgrounds, etc. It seems you should get want you want.
in terms of hdpi folders, etc, this too is automatically chosen by the phone, based on its resolution, etc, and you always reference simply as 'drawable' in your XML.
Q:Also, my png is named: status_bar_item_background_normal.9.png. Which is different from "status_bar_background." Will the system know what png I'm wanting to use even though it's not named the same?
A: status_bar_background is typically just the curtain, again, based on how your XML is laid out, meaning the background beneath the notifications but above the "drag bar".
Disclaimer:
If you have a customized .9 png (be careful, you must use care when editing .9 pngs as they have meta information on how they can be stretched), you can change the background to point to the exact name (less the .9.png extension, instead of status_bar_background) and see what happens.
You may also want to consider decompiling some of the SystemUI.apk files I recently posted, as I had to re-arrange some of the background settings to get things to show how I wanted, and it may help you see what I did as an example.
How to Remap the clear button:
Note: The below picture represents the clear button remap before liamstears edited it. With the below code, the clear button will be fixed and the blank status bar should no longer appear.
Credit:liamstears
Found in:res/layout/status_bar_expanded.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<com.android.systemui.statusbar.ExpandedView android:orientation="horizontal" android:focusable="true" android:descendantFocusability="afterDescendants"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content">
<LinearLayout android:gravity="center_vertical" android:orientation="horizontal" android:background="@drawable/status_bar_header_background" android:paddingRight="@dimen/clear_button_padding_right" android:layout_width="fill_parent" android:layout_height="wrap_content">
<com.android.systemui.statusbar.CarrierLabel android:gravity="center_vertical" android:layout_gravity="center_vertical" android:orientation="vertical" android:id="@id/carrierLabel" android:paddingLeft="5.0dip" android:paddingTop="1.0dip" android:paddingBottom="1.0dip" android:layout_width="0.0dip" android:layout_height="wrap_content" android:layout_weight="1.0">
<com.htc.widget.HtcBlinkingTextView android:textAppearance="?android:textAppearanceLarge" android:textSize="@dimen/status_bar_title_font_size" android:textColor="#ffffffff" android:layout_gravity="center_vertical" android:id="@id/plmnLabel" android:paddingLeft="4.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:textAppearance="?android:textAppearanceLarge" android:textSize="@dimen/status_bar_title_font_size" android:textColor="#ffffffff" android:layout_gravity="center_vertical" android:id="@id/spnLabel" android:paddingLeft="4.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</com.android.systemui.statusbar.CarrierLabel>
</LinearLayout>
<FrameLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1.0">
<ScrollView android:id="@id/scroll" android:fadingEdge="none" android:layout_width="fill_parent" android:layout_height="fill_parent" android:overScrollMode="ifContentScrolls">
<com.android.systemui.statusbar.NotificationLinearLayout android:orientation="vertical" android:id="@id/notificationLinearLayout" android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:textAppearance="@style/TextAppearance.StatusBar.Title" android:id="@id/noNotificationsTitle" android:background="@drawable/title_bar_portrait" android:paddingLeft="14.0px" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/status_bar_no_notifications_title" />
<TextView android:textAppearance="@style/TextAppearance.StatusBar.Title" android:id="@id/ongoingTitle" android:background="@drawable/title_bar_portrait" android:paddingLeft="14.0px" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/status_bar_ongoing_events_title" />
<LinearLayout android:orientation="vertical" android:id="@id/ongoingItems" android:layout_width="fill_parent" android:layout_height="wrap_content" android:drawable="@drawable/list_item_background" />
<TextView android:textAppearance="@style/TextAppearance.StatusBar.Title" android:id="@id/latestTitle" android:background="@drawable/title_bar_portrait" android:paddingLeft="14.0px" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/status_bar_latest_events_title" />
<LinearLayout android:orientation="vertical" android:id="@id/latestItems" android:layout_width="fill_parent" android:layout_height="wrap_content" android:drawable="@drawable/list_item_background" />
<TextView android:textSize="@dimen/clear_button_font_size" android:textColor="#ffffffff" android:layout_gravity="center" android:id="@id/clear_all_button" android:background="@drawable/btn_default_small" android:layout_width="fill_parent" android:layout_height="40.0dip" android:text="@string/status_bar_clear_all_button" style="?android:buttonStyle" />
</com.android.systemui.statusbar.NotificationLinearLayout>
</ScrollView>
<ImageView android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/title_bar_shadow" android:scaleType="fitXY" />
</FrameLayout>
</LinearLayout>
<ImageView android:id="@id/tab_divider" android:layout_width="2.0px" android:layout_height="fill_parent" android:src="@drawable/notification_separator" android:scaleType="fitXY" />
</com.android.systemui.statusbar.ExpandedView>
The main line that makes this work is as follows:
Code:
<TextView android:textSize="@dimen/clear_button_font_size" android:textColor="#ffffffff" android:layout_gravity="center" android:id="@id/clear_all_button" android:background="@drawable/btn_default_small" android:layout_width="fill_parent" android:layout_height="40.0dip" android:text="@string/status_bar_clear_all_button" style="?android:buttonStyle" />
Once again good job man!
btw the original instructions for transparency can be found here. I believe they were the same ones wolf gave you ;-)
http://forum.xda-developers.com/showpost.php?p=15199389&postcount=1237
and what is this about jschisurf? He's still around! woot woot
Dude what's that theme that your using? It looks awesome!
Sent from my ADR6300 using XDA App
tommytomatoe said:
Once again good job man!
btw the original instructions for transparency can be found here. I believe they were the same ones wolf gave you ;-)
http://forum.xda-developers.com/showpost.php?p=15199389&postcount=1237
and what is this about jschisurf? He's still around! woot woot
Click to expand...
Click to collapse
Awesome thread you posted. Thanks. I'm sure I missed something because the quick setttings status bar isn't transparent like the notification bar is. I'm sure I'll figure out what I did wrong after reading your post, thanks.

XML Editing help please!

Hey guys,
I'm just finishing up work on my theme but there is just one part which I cannot get the way I like it. Unfortuantely it is involved with a widget which I cannot change just by messing with a jpg in Photoshop or changing rows/columns in LauncherPro etc.
My problem is with Fancy Widgets. I'm trying to make a row of 'forecast' icons with a small 'day' label above them. Now, Fancy Widgets (I'm using the paid version) comes with 2 types of 4x1 (horizontal) widgets which do exactly this, shown here:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Ignore the temperature; fancy widgets can hide this element.
Now, if you look closely, the top widget has slightly bigger icons, which I want, but the day text is below the icons and quite a bit far away; where as the bottom widget has the text perfectly in place, but the icons are smaller, which I don't want
So, what am I to do? Let's get down and dirty with some XML editing
Now, I've extracted the apk with APKManager and found (what I think are) the 2x XML's in questions:
widget_14_forecast.xml
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<include layout="\@layout/base" />
<LinearLayout androidrientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_marginLeft="10.0dip" android:layout_marginTop="2.0dip" android:layout_marginRight="10.0dip" android:layout_marginBottom="5.0dip" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_centerVertical="true">
<LinearLayout android:gravity="center_horizontal" androidrientation="vertical" android:id="@id/fc_day0" android:layout_width="0.0dip" android:layout_height="wrap_content" android:layout_weight="1.0">
<ImageView android:id="@id/icon_day0" android:layout_width="fill_parent" android:layout_height="60.0dip" android:scaleType="centerInside" />
<TextView android:textSize="12.0sp" android:id="@id/temp_day0" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="-3.0dip" style="\@style/textStyleShadow" />
<TextView android:textSize="12.0sp" android:gravity="center" android:id="@id/dow_day0" android:layout_width="wrap_content" android:layout_height="wrap_content" style="\@style/textStyleShadow" />
</LinearLayout>
<LinearLayout android:gravity="center_horizontal" androidrientation="vertical" android:id="@id/fc_day1" android:layout_width="0.0dip" android:layout_height="wrap_content" android:layout_weight="1.0">
<ImageView android:id="@id/icon_day1" android:layout_width="fill_parent" android:layout_height="60.0dip" android:scaleType="centerInside" />
<TextView android:textSize="12.0sp" android:id="@id/temp_day1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="-3.0dip" style="\@style/textStyleShadow" />
<TextView android:textSize="12.0sp" android:gravity="center" android:id="@id/dow_day1" android:layout_width="wrap_content" android:layout_height="wrap_content" style="\@style/textStyleShadow" />
</LinearLayout>
<LinearLayout android:gravity="center_horizontal" androidrientation="vertical" android:id="@id/fc_day2" android:layout_width="0.0dip" android:layout_height="wrap_content" android:layout_weight="1.0">
<ImageView android:id="@id/icon_day2" android:layout_width="fill_parent" android:layout_height="60.0dip" android:scaleType="centerInside" />
<TextView android:textSize="12.0sp" android:id="@id/temp_day2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="-3.0dip" style="\@style/textStyleShadow" />
<TextView android:textSize="12.0sp" android:gravity="center" android:id="@id/dow_day2" android:layout_width="wrap_content" android:layout_height="wrap_content" style="\@style/textStyleShadow" />
</LinearLayout>
<LinearLayout android:gravity="center_horizontal" androidrientation="vertical" android:id="@id/fc_day3" android:layout_width="0.0dip" android:layout_height="wrap_content" android:layout_weight="1.0">
<ImageView android:id="@id/icon_day3" android:layout_width="fill_parent" android:layout_height="60.0dip" android:scaleType="centerInside" />
<TextView android:textSize="12.0sp" android:id="@id/temp_day3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="-3.0dip" style="\@style/textStyleShadow" />
<TextView android:textSize="12.0sp" android:gravity="center" android:id="@id/dow_day3" android:layout_width="wrap_content" android:layout_height="wrap_content" style="\@style/textStyleShadow" />
</LinearLayout>
<LinearLayout android:gravity="center_horizontal" androidrientation="vertical" android:id="@id/fc_day4" android:layout_width="0.0dip" android:layout_height="wrap_content" android:layout_weight="1.0">
<ImageView android:id="@id/icon_day4" android:layout_width="fill_parent" android:layout_height="60.0dip" android:scaleType="centerInside" />
<TextView android:textSize="12.0sp" android:id="@id/temp_day4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="-3.0dip" style="\@style/textStyleShadow" />
<TextView android:textSize="12.0sp" android:gravity="center" android:id="@id/dow_day4" android:layout_width="wrap_content" android:layout_height="wrap_content" style="\@style/textStyleShadow" />
</LinearLayout>
</LinearLayout>
<TextView android:gravity="center" android:id="@id/empty_forecast" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/no_forecast_msg" android:layout_centerHorizontal="true" android:layout_centerVertical="true" style="\@style/textStyleShadow" />
</RelativeLayout>
Click to expand...
Click to collapse
widget_14_forecast_alt.xml
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<include layout="\@layout/base" />
<LinearLayout androidrientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_marginLeft="10.0dip" android:layout_marginTop="10.0dip" android:layout_marginRight="10.0dip" android:layout_marginBottom="8.0dip" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_centerVertical="true">
<LinearLayout android:gravity="center_horizontal" androidrientation="vertical" android:id="@id/fc_day0" android:layout_width="0.0dip" android:layout_height="wrap_content" android:layout_weight="1.0">
<TextView android:textSize="12.0sp" android:gravity="center" android:id="@id/dow_day0" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="-4.0dip" style="\@style/textStyleShadow" />
<ImageView android:id="@id/icon_day0" android:layout_width="fill_parent" android:layout_height="52.0dip" android:scaleType="centerInside" />
<TextView android:textSize="12.0sp" android:id="@id/temp_day0" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="-4.0dip" style="\@style/textStyleShadow" />
</LinearLayout>
<LinearLayout android:gravity="center_horizontal" androidrientation="vertical" android:id="@id/fc_day1" android:layout_width="0.0dip" android:layout_height="wrap_content" android:layout_weight="1.0">
<TextView android:textSize="12.0sp" android:gravity="center" android:id="@id/dow_day1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="-4.0dip" style="\@style/textStyleShadow" />
<ImageView android:id="@id/icon_day1" android:layout_width="fill_parent" android:layout_height="52.0dip" android:scaleType="centerInside" />
<TextView android:textSize="12.0sp" android:id="@id/temp_day1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="-4.0dip" style="\@style/textStyleShadow" />
</LinearLayout>
<LinearLayout android:gravity="center_horizontal" androidrientation="vertical" android:id="@id/fc_day2" android:layout_width="0.0dip" android:layout_height="wrap_content" android:layout_weight="1.0">
<TextView android:textSize="12.0sp" android:gravity="center" android:id="@id/dow_day2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="-4.0dip" style="\@style/textStyleShadow" />
<ImageView android:id="@id/icon_day2" android:layout_width="fill_parent" android:layout_height="52.0dip" android:scaleType="centerInside" />
<TextView android:textSize="12.0sp" android:id="@id/temp_day2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="-4.0dip" style="\@style/textStyleShadow" />
</LinearLayout>
<LinearLayout android:gravity="center_horizontal" androidrientation="vertical" android:id="@id/fc_day3" android:layout_width="0.0dip" android:layout_height="wrap_content" android:layout_weight="1.0">
<TextView android:textSize="12.0sp" android:gravity="center" android:id="@id/dow_day3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="-4.0dip" style="\@style/textStyleShadow" />
<ImageView android:id="@id/icon_day3" android:layout_width="fill_parent" android:layout_height="52.0dip" android:scaleType="centerInside" />
<TextView android:textSize="12.0sp" android:id="@id/temp_day3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="-4.0dip" style="\@style/textStyleShadow" />
</LinearLayout>
<LinearLayout android:gravity="center_horizontal" androidrientation="vertical" android:id="@id/fc_day4" android:layout_width="0.0dip" android:layout_height="wrap_content" android:layout_weight="1.0">
<TextView android:textSize="12.0sp" android:gravity="center" android:id="@id/dow_day4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="-4.0dip" style="\@style/textStyleShadow" />
<ImageView android:id="@id/icon_day4" android:layout_width="fill_parent" android:layout_height="52.0dip" android:scaleType="centerInside" />
<TextView android:textSize="12.0sp" android:id="@id/temp_day4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="-4.0dip" style="\@style/textStyleShadow" />
</LinearLayout>
</LinearLayout>
<TextView android:gravity="center" android:id="@id/empty_forecast" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/no_forecast_msg" android:layout_centerHorizontal="true" android:layout_centerVertical="true" style="\@style/textStyleShadow" />
</RelativeLayout>
Click to expand...
Click to collapse
Now; looks to me that the top xml I quoted is the top widget in the pic.
What I tried to do, was change the android:layout_height="52.0dip" in the 2nd one to a 60.0dip to try and make the icons bigger.
From then I recompiled & resigned the apk with APKManger, reinstalled the new Fancy Widgets and gave it a go.... Huge fail; Now the 4x1 widget will just show "Widget Failed To Load"... or equivilant.
Anyone be able to point me in the right direction?
Many thanks dudes
Mumpty bump PLZ!
I think what happened was when the day text was on top of the weather icon, it crunched the icons to a smaller size due to widget size.
Instead of using 60, why not try 53.0dip and see what happens? You may have set too great of a number for it to show properly in the widget.
Not entirely sure but I'd go with 53.0dip, since original was 52.0dip, instead of 60.0dip.
Usually when I theme, and I have a problem with something, I'll look at an original XML and see what they did to make it look the way it should.
Thanks TheSwaggeR. I gave up pretty quickly - I may have tried a lower number & it still didn't work.
After lots of searching (Root Explorer has a terrible search!), I found that the weather icons were stored on the SDCard - I manually changed the size of the .png files and it worked a treat

[4.2] [QuickSettings] How to add new toggles to 4.2 Android

Original Post By Lithid-cm . Quoted Here so some can Learn​
lithid-cm said:
This is just going to be a quick rundown on what do to add new toggles to android new QuickSettings system. This will take place in SystemUI.
Custom QuickSettings Toggles
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Path: frameworks/base/packages/SystemUI
Files:
src/com/android/systemui/statusbar/phone/QuickSettings.java
There are two options when creating a toggle.
addSystemTiles:380 - Static tiles with useful information.
addTemporaryTiles:571 - This type of tile will get removed without activity, for example, the alarm quick setting is a temp tile.
I used SystemTiles
Code:
// CpuInfo tile
QuickSettingsTileView cpuInfoTile = (QuickSettingsTileView)
inflater.inflate(R.layout.quick_settings_tile, parent, false);
cpuInfoTile.setContent(R.layout.quick_settings_tile_cpuinfo, inflater);
cpuInfoTile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startSettingsActivity(Intent.ACTION_POWER_USAGE_SUMMARY);
}
});
mModel.addCpuInfoTile(cpuInfoTile, new QuickSettingsModel.RefreshCallback() {
@Override
public void refreshView(QuickSettingsTileView view, State state) {
ImageView iv = (ImageView) view.findViewById(R.id.cpuinfo_image);
TextView tva = (TextView) view.findViewById(R.id.cpuinfoa_textview);
TextView tvb = (TextView) view.findViewById(R.id.cpuinfob_textview);
Drawable d = mContext.getResources().getDrawable(R.drawable.ic_settings_performance);
String GOV = fileReadOneLine(GOV_FILE);
String FREQ = fileReadOneLine(SCALE_CUR_FILE);
iv.setImageDrawable(d);
tva.setText(GOV);
tvb.setText(FREQ);
view.setContentDescription(
mContext.getString(R.string.accessibility_quick_settings_cpuinfo, GOV));
}
});
parent.addView(cpuInfoTile);
src/com/android/systemui/statusbar/phone/QuickSettingsModel.java:174
This is needed for the widget inside the toggle to get updated. You can view other definitions in here to update various states.
Code:
private QuickSettingsTileView mCpuInfoTile;
private RefreshCallback mCpuInfoCallback;
private State mCpuInfoState = new State();
res/layout/quick_settings_tile_cpuinfo.xml
This is where we create the layout of the tile and call it from java.
Code:
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/cpuinfo_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingBottom="10dp"
/>
<TextView
style="@style/TextAppearance.QuickSettings.TileView"
android:id="@+id/cpuinfoa_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#287AA9"
android:gravity="center"
/>
<TextView
style="@style/TextAppearance.QuickSettings.TileView"
android:id="@+id/cpuinfob_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#287AA9"
android:gravity="center"
/>
</LinearLayout>
res/values/strings.xml
Needed to setContentDescription()
Code:
<string name="accessibility_quick_settings_cpuinfo">CpuInfo <xliff:g id="meminfo" example="CpuInfo">%s</xliff:g>.</string>
I know this is a very general overview, but the actuality is there is so much that can be done with this, it would be hard to go into extreme detail. Would be better to just simply leave that stuff for questions in this thread.
If you want to know more, please just ask. Lets make android OURS!​
Click to expand...
Click to collapse

XML 101 - XML Modding Made Easy!

{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
http://tinyurl.com/xmlmadeeasy​
If you're modding Android, eventually you're going to have to edit some XML.
Want to center the clock in your statusbar? Rearrange the icons in your navbar? Change the layout of your notification screen? Get rid of a carrier label? Change the colour of some text?
Then you need to edit some XML files.
And you might not have any idea how...
Well, don't worry. The purpose of this thread is to show you just easy XML-editing can be. Once you've read it, you'll be one step closer to being an XML expert!
This guide is meant for noobs, experienced modders and everyone in between. Hopefully everybody can learn something..
Here's what this thread has to offer so far:
- Introduction (This Post)
- How To Delete A Line (Yes, Really) - http://forum.xda-developers.com/showpost.php?p=56522113&postcount=2
- Some Useful Codes To Know - http://forum.xda-developers.com/showpost.php?p=56522122&postcount=3
- How To Change The Colour Of The Status Bar Clock - http://forum.xda-developers.com/showpost.php?p=56522123&postcount=4
- How To Put An Invisible Softkey In The Status Bar - http://forum.xda-developers.com/showpost.php?p=56522135&postcount=5
- How To Center The Clock In The Status Bar...Part 1 - http://forum.xda-developers.com/showpost.php?p=56522157&postcount=6
- How To Center The Clock In The Status Bar...Part 2 - http://forum.xda-developers.com/showpost.php?p=56522168&postcount=7
- Centering The Clock In Xperia KitKat - http://forum.xda-developers.com/showpost.php?p=59569708&postcount=297
- android:layout_gravity, android:gravity AND android:layout_weight - http://forum.xda-developers.com/showpost.php?p=56522180&postcount=8
- Do NOT Edit "public.xml"!! - http://forum.xda-developers.com/showpost.php?p=56522194&postcount=9​
I also encourage others to post guides as well:
- How To Remove "am/pm" From The Clock On Pre-4.2 Roms (by @KronicSkillz) - http://forum.xda-developers.com/showpost.php?p=56624586&postcount=17​
- How To Swap The Notification And Status Bar Icons (by @Anmol0022) - http://forum.xda-developers.com/showpost.php?p=57959079&postcount=115​
- How To Hide A Centered Status Bar Clock When A Lollipop Device Is Locked (by @S0bes) - http://forum.xda-developers.com/showpost.php?p=58460343&postcount=172​There will be more coming soon!!
*** What Is XML? ***​
'XML' stands for 'eXtensible Markup Language'. But you don't need to know that.
What you need to know is that XML is used by Google to define the layout of Android applications.
Look at your statusbar. It's Java that controls how your statusbar works, but it's XML that controls where everything on it is.
(If you want to edit the Java, you can try building the app from source. Or look at editing smali. Smali is harder to understand than XML but there's a great guide by @Goldie here: http://forum.xda-developers.com/galaxy-s2/development-derivatives/guide-understanding-creating-smali-mods-t2488033)
*** Where Can I Find An App's XML? ***​
To edit an app's XML, you first need to be able to access it. To do that, you need to decompile the .apk file. If you don't decompile, any XML you try editing won't work.
There are enough tutorials on xda to tell you how to do this that I don't need to fill up space here telling you about it.
But I always recommend using Tickle My Android (http://forum.xda-developers.com/showthread.php?t=1633333) for any decompiling and recompiling.
*** What Does XML Look Like? ***​
This is the line of XML that displays the clock on my phone's statusbar:
Code:
<com.android.systemui.statusbar.policy.Clock android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:gravity="start|center" android:id="@id/clock" android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleLine="true" android:paddingStart="6.0dip" />
One of the great things about XML is that it ignores whitespace. Or, in other words, we can do stuff like this:
Code:
<com.android.systemui.statusbar.policy.Clock
android:textAppearance="@style/TextAppearance.StatusBar.Clock"
android:gravity="start|center"
android:id="@id/clock"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:singleLine="true"
android:paddingStart="6.0dip"
/>
Looks a bit more sensible, doesn't it? In theory, you can do this to every single line in a XML file but that'd be time-consuming and a bit pointless.
XML consists of two parts: 'tags' and 'attributes'. Google also like to talk about 'Views' and 'ViewGroups', but we won't worry about that for now.
Essentially, a tag is something you see (even if it's invisible) and an attribute affects the way that tag works. Let's look at that code again with the tags and attributes highlighted..
Code:
[color="red"]<com.android.systemui.statusbar.policy.Clock
[color="blue"] android:textAppearance="@style/TextAppearance.StatusBar.Clock"
android:gravity="start|center"
android:id="@id/clock"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:singleLine="true"
android:paddingStart="6.0dip"[/color]
/>[/color]
Hopefully that code is starting to make a bit more sense. If not, don't worry. The more you edit XML, the more you'll understand it.
We can change those attributes, remove some and add others. And at the end of it all, that clock can look completely different.
And that's before we start moving the line to somewhere else in the XML file and adding other tags. With a little work, and a little patience, we can make a massive difference to our Android device.
*** What Do I Need To Know To Start Modding XML Myself? ***​
This is the 'status_bar.xml' from my rom. I have an Xperia Z, runnning stock Sony-themed KitKat, modified by myself and this XML file can be found in 'system/priv-app/SystemUI.apk'.
Code:
<?xml version="1.0" encoding="utf-8"?>
<com.android.systemui.statusbar.phone.PhoneStatusBarView android:orientation="vertical" android:id="@id/status_bar" android:background="@drawable/system_bar_background" android:focusable="true" android:fitsSystemWindows="true" android:descendantFocusability="afterDescendants"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui">
<FrameLayout android:id="@id/ongoing_call_bg_parent_layout" android:background="@color/ongoing_call_bg_color" android:visibility="gone" android:layout_width="fill_parent" android:layout_height="fill_parent">
<ImageView android:layout_gravity="left" android:id="@id/ongoing_call_glow" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</FrameLayout>
<ImageView android:id="@id/notification_lights_out" android:paddingBottom="2.0dip" android:visibility="gone" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="fill_parent" android:src="@drawable/ic_sysbar_lights_out_dot_small" android:scaleType="center" android:paddingStart="6.0dip" />
<com.sonymobile.systemui.statusbar.operator.OperatorLabel android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:ellipsize="marquee" android:gravity="start|center" android:id="@id/operator" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleLine="true" android:paddingStart="6.0dip" android:paddingEnd="4.0dip" />
<LinearLayout android:orientation="horizontal" android:id="@id/status_bar_contents" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingStart="6.0dip" android:paddingEnd="6.0dip">
<RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent">
<com.panel.Button android:id="@id/button" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_alignParentStart="true" />
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentStart="true">
<com.android.systemui.statusbar.StatusBarIconView android:id="@id/moreIcon" android:visibility="gone" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="fill_parent" android:src="@drawable/stat_notify_more" />
<com.android.systemui.statusbar.phone.IconPartitioner android:id="@id/notification_icon_area" android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0">
<com.android.systemui.statusbar.phone.IconMerger android:gravity="center_vertical" android:orientation="horizontal" android:id="@id/notificationIcons" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_alignParentStart="true" />
<LinearLayout android:orientation="horizontal" android:id="@id/system_icon_area" android:layout_width="wrap_content" android:layout_height="fill_parent">
<com.panel.Panel android:id="@id/panel" android:layout_width="wrap_content" android:layout_height="fill_parent">
<LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="fill_parent" />
<LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="fill_parent">
<com.android.systemui.statusbar.policy.Traffic android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:gravity="start|center" android:id="@id/traffic" android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleLine="true" />
</LinearLayout>
</com.panel.Panel>
<LinearLayout android:gravity="center_vertical" android:orientation="horizontal" android:id="@id/statusIcons" android:layout_width="wrap_content" android:layout_height="fill_parent" />
</LinearLayout>
</com.android.systemui.statusbar.phone.IconPartitioner>
<LinearLayout android:gravity="center" android:orientation="horizontal" android:id="@id/signal_battery_cluster" android:layout_width="wrap_content" android:layout_height="fill_parent" android:paddingStart="2.0dip">
<include android:id="@id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" layout="@layout/signal_cluster_view" />
<LinearLayout android:id="@id/battery" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginStart="4.0dip">
<ImageView android:layout_gravity="center_vertical" android:id="@id/status" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<com.erryy.BatteryText android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:gravity="start|center" android:layout_width="wrap_content" android:layout_height="fill_parent" android:paddingStart="1.0dip" />
<LinearLayout android:id="@id/battery_meter" android:layout_width="0.0dip" android:layout_height="0.0dip">
<ImageView android:layout_gravity="center_vertical" android:id="@id/battery_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<ImageView android:layout_gravity="center_vertical" android:id="@id/stamina_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/somc_sys_powersaver" />
</LinearLayout>
<FrameLayout android:id="@id/battery_percent" android:layout_width="wrap_content" android:layout_height="fill_parent">
<com.sonymobile.systemui.statusbar.BatteryImage android:layout_gravity="start|center" android:id="@id/battery_percent_bg" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</FrameLayout>
</LinearLayout>
</LinearLayout>
<com.android.systemui.statusbar.policy.Clock android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:gravity="start|center" android:id="@id/clock" android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleLine="true" android:paddingStart="6.0dip" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout android:orientation="horizontal" android:id="@id/ticker" android:animationCache="false" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingStart="6.0dip">
<ImageSwitcher android:id="@id/tickerIcon" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:layout_marginEnd="4.0dip">
<com.android.systemui.statusbar.AnimatedImageView android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:scaleType="center" />
<com.android.systemui.statusbar.AnimatedImageView android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:scaleType="center" />
</ImageSwitcher>
<com.android.systemui.statusbar.phone.TickerView android:id="@id/tickerText" android:paddingTop="2.0dip" android:layout_width="0.0dip" android:layout_height="wrap_content" android:layout_weight="1.0" android:paddingEnd="10.0dip">
<TextView android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker" android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="true" android:textAlignment="viewStart" />
<TextView android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker" android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="true" android:textAlignment="viewStart" />
</com.android.systemui.statusbar.phone.TickerView>
</LinearLayout>
<ImageView android:layout_gravity="top|left|center" android:id="@id/rounded_corner_ul" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/rounded_corner_ul" />
<ImageView android:layout_gravity="top|right|center" android:id="@id/rounded_corner_ur" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/rounded_corner_ur" />
</com.android.systemui.statusbar.phone.PhoneStatusBarView>
If you understand every single line, tag and attribute then you can skip the next three posts. You're clearly an expert and I should probably be calling you 'Sir'...
If you don't, then read on. Hopefully you can see that, even though there's a lot of code there, it's all just tags and attributes. That's all that XML is. It's easier than it looks.
I have a few more things to tell you, then I'll show you a few example mods. Then it'd be time for you to practice editing XML for yourself.
*** How To Delete A Line (Yes, Really) ***​
That's right.
I'm dedicating an entire post to teach you how to use the DELETE button.
I'm nuts, right?
Actually...no. (Although my therapist would disagree!)
Let's have a look at that status_bar.xml again:
Code:
<?xml version="1.0" encoding="utf-8"?>
<com.android.systemui.statusbar.phone.PhoneStatusBarView android:orientation="vertical" android:id="@id/status_bar" android:background="@drawable/system_bar_background" android:focusable="true" android:fitsSystemWindows="true" android:descendantFocusability="afterDescendants"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui">
<FrameLayout android:id="@id/ongoing_call_bg_parent_layout" android:background="@color/ongoing_call_bg_color" android:visibility="gone" android:layout_width="fill_parent" android:layout_height="fill_parent">
<ImageView android:layout_gravity="left" android:id="@id/ongoing_call_glow" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</FrameLayout>
<ImageView android:id="@id/notification_lights_out" android:paddingBottom="2.0dip" android:visibility="gone" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="fill_parent" android:src="@drawable/ic_sysbar_lights_out_dot_small" android:scaleType="center" android:paddingStart="6.0dip" />
<com.sonymobile.systemui.statusbar.operator.OperatorLabel android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:ellipsize="marquee" android:gravity="start|center" android:id="@id/operator" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleLine="true" android:paddingStart="6.0dip" android:paddingEnd="4.0dip" />
<LinearLayout android:orientation="horizontal" android:id="@id/status_bar_contents" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingStart="6.0dip" android:paddingEnd="6.0dip">
<RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent">
<com.panel.Button android:id="@id/button" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_alignParentStart="true" />
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentStart="true">
<com.android.systemui.statusbar.StatusBarIconView android:id="@id/moreIcon" android:visibility="gone" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="fill_parent" android:src="@drawable/stat_notify_more" />
<com.android.systemui.statusbar.phone.IconPartitioner android:id="@id/notification_icon_area" android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0">
<com.android.systemui.statusbar.phone.IconMerger android:gravity="center_vertical" android:orientation="horizontal" android:id="@id/notificationIcons" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_alignParentStart="true" />
<LinearLayout android:orientation="horizontal" android:id="@id/system_icon_area" android:layout_width="wrap_content" android:layout_height="fill_parent">
<com.panel.Panel android:id="@id/panel" android:layout_width="wrap_content" android:layout_height="fill_parent">
<LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="fill_parent" />
<LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="fill_parent">
<com.android.systemui.statusbar.policy.Traffic android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:gravity="start|center" android:id="@id/traffic" android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleLine="true" />
</LinearLayout>
</com.panel.Panel>
<LinearLayout android:gravity="center_vertical" android:orientation="horizontal" android:id="@id/statusIcons" android:layout_width="wrap_content" android:layout_height="fill_parent" />
</LinearLayout>
</com.android.systemui.statusbar.phone.IconPartitioner>
<LinearLayout android:gravity="center" android:orientation="horizontal" android:id="@id/signal_battery_cluster" android:layout_width="wrap_content" android:layout_height="fill_parent" android:paddingStart="2.0dip">
<include android:id="@id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" layout="@layout/signal_cluster_view" />
<LinearLayout android:id="@id/battery" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginStart="4.0dip">
[COLOR="Red"] <ImageView android:layout_gravity="center_vertical" android:id="@id/status" android:layout_width="wrap_content" android:layout_height="wrap_content" />[/color]
<com.erryy.BatteryText android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:gravity="start|center" android:layout_width="wrap_content" android:layout_height="fill_parent" android:paddingStart="1.0dip" />
<LinearLayout android:id="@id/battery_meter" android:layout_width="0.0dip" android:layout_height="0.0dip">
<ImageView android:layout_gravity="center_vertical" android:id="@id/battery_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<ImageView android:layout_gravity="center_vertical" android:id="@id/stamina_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/somc_sys_powersaver" />
</LinearLayout>
<FrameLayout android:id="@id/battery_percent" android:layout_width="wrap_content" android:layout_height="fill_parent">
<com.sonymobile.systemui.statusbar.BatteryImage android:layout_gravity="start|center" android:id="@id/battery_percent_bg" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</FrameLayout>
</LinearLayout>
</LinearLayout>
<com.android.systemui.statusbar.policy.Clock android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:gravity="start|center" android:id="@id/clock" android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleLine="true" android:paddingStart="6.0dip" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout android:orientation="horizontal" android:id="@id/ticker" android:animationCache="false" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingStart="6.0dip">
<ImageSwitcher android:id="@id/tickerIcon" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:layout_marginEnd="4.0dip">
<com.android.systemui.statusbar.AnimatedImageView android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:scaleType="center" />
<com.android.systemui.statusbar.AnimatedImageView android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:scaleType="center" />
</ImageSwitcher>
<com.android.systemui.statusbar.phone.TickerView android:id="@id/tickerText" android:paddingTop="2.0dip" android:layout_width="0.0dip" android:layout_height="wrap_content" android:layout_weight="1.0" android:paddingEnd="10.0dip">
<TextView android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker" android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="true" android:textAlignment="viewStart" />
<TextView android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker" android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="true" android:textAlignment="viewStart" />
</com.android.systemui.statusbar.phone.TickerView>
</LinearLayout>
<ImageView android:layout_gravity="top|left|center" android:id="@id/rounded_corner_ul" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/rounded_corner_ul" />
<ImageView android:layout_gravity="top|right|center" android:id="@id/rounded_corner_ur" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/rounded_corner_ur" />
</com.android.systemui.statusbar.phone.PhoneStatusBarView>
This is the XML that defines the layout of my phone's statusbar. Let's say that I wanted to stop the status icons from showing. That's the line in red above.
I'd just delete it right?
Code:
<?xml version="1.0" encoding="utf-8"?>
<com.android.systemui.statusbar.phone.PhoneStatusBarView android:orientation="vertical" android:id="@id/status_bar" android:background="@drawable/system_bar_background" android:focusable="true" android:fitsSystemWindows="true" android:descendantFocusability="afterDescendants"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui">
<FrameLayout android:id="@id/ongoing_call_bg_parent_layout" android:background="@color/ongoing_call_bg_color" android:visibility="gone" android:layout_width="fill_parent" android:layout_height="fill_parent">
<ImageView android:layout_gravity="left" android:id="@id/ongoing_call_glow" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</FrameLayout>
<ImageView android:id="@id/notification_lights_out" android:paddingBottom="2.0dip" android:visibility="gone" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="fill_parent" android:src="@drawable/ic_sysbar_lights_out_dot_small" android:scaleType="center" android:paddingStart="6.0dip" />
<com.sonymobile.systemui.statusbar.operator.OperatorLabel android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:ellipsize="marquee" android:gravity="start|center" android:id="@id/operator" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleLine="true" android:paddingStart="6.0dip" android:paddingEnd="4.0dip" />
<LinearLayout android:orientation="horizontal" android:id="@id/status_bar_contents" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingStart="6.0dip" android:paddingEnd="6.0dip">
<RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent">
<com.panel.Button android:id="@id/button" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_alignParentStart="true" />
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentStart="true">
<com.android.systemui.statusbar.StatusBarIconView android:id="@id/moreIcon" android:visibility="gone" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="fill_parent" android:src="@drawable/stat_notify_more" />
<com.android.systemui.statusbar.phone.IconPartitioner android:id="@id/notification_icon_area" android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0">
<com.android.systemui.statusbar.phone.IconMerger android:gravity="center_vertical" android:orientation="horizontal" android:id="@id/notificationIcons" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_alignParentStart="true" />
<LinearLayout android:orientation="horizontal" android:id="@id/system_icon_area" android:layout_width="wrap_content" android:layout_height="fill_parent">
<com.panel.Panel android:id="@id/panel" android:layout_width="wrap_content" android:layout_height="fill_parent">
<LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="fill_parent" />
<LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="fill_parent">
<com.android.systemui.statusbar.policy.Traffic android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:gravity="start|center" android:id="@id/traffic" android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleLine="true" />
</LinearLayout>
</com.panel.Panel>
<LinearLayout android:gravity="center_vertical" android:orientation="horizontal" android:id="@id/statusIcons" android:layout_width="wrap_content" android:layout_height="fill_parent" />
</LinearLayout>
</com.android.systemui.statusbar.phone.IconPartitioner>
<LinearLayout android:gravity="center" android:orientation="horizontal" android:id="@id/signal_battery_cluster" android:layout_width="wrap_content" android:layout_height="fill_parent" android:paddingStart="2.0dip">
<include android:id="@id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" layout="@layout/signal_cluster_view" />
<LinearLayout android:id="@id/battery" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginStart="4.0dip">
<com.erryy.BatteryText android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:gravity="start|center" android:layout_width="wrap_content" android:layout_height="fill_parent" android:paddingStart="1.0dip" />
<LinearLayout android:id="@id/battery_meter" android:layout_width="0.0dip" android:layout_height="0.0dip">
<ImageView android:layout_gravity="center_vertical" android:id="@id/battery_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<ImageView android:layout_gravity="center_vertical" android:id="@id/stamina_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/somc_sys_powersaver" />
</LinearLayout>
<FrameLayout android:id="@id/battery_percent" android:layout_width="wrap_content" android:layout_height="fill_parent">
<com.sonymobile.systemui.statusbar.BatteryImage android:layout_gravity="start|center" android:id="@id/battery_percent_bg" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</FrameLayout>
</LinearLayout>
</LinearLayout>
<com.android.systemui.statusbar.policy.Clock android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:gravity="start|center" android:id="@id/clock" android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleLine="true" android:paddingStart="6.0dip" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout android:orientation="horizontal" android:id="@id/ticker" android:animationCache="false" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingStart="6.0dip">
<ImageSwitcher android:id="@id/tickerIcon" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:layout_marginEnd="4.0dip">
<com.android.systemui.statusbar.AnimatedImageView android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:scaleType="center" />
<com.android.systemui.statusbar.AnimatedImageView android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:scaleType="center" />
</ImageSwitcher>
<com.android.systemui.statusbar.phone.TickerView android:id="@id/tickerText" android:paddingTop="2.0dip" android:layout_width="0.0dip" android:layout_height="wrap_content" android:layout_weight="1.0" android:paddingEnd="10.0dip">
<TextView android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker" android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="true" android:textAlignment="viewStart" />
<TextView android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker" android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="true" android:textAlignment="viewStart" />
</com.android.systemui.statusbar.phone.TickerView>
</LinearLayout>
<ImageView android:layout_gravity="top|left|center" android:id="@id/rounded_corner_ul" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/rounded_corner_ul" />
<ImageView android:layout_gravity="top|right|center" android:id="@id/rounded_corner_ur" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/rounded_corner_ur" />
</com.android.systemui.statusbar.phone.PhoneStatusBarView>
No.
Try this and as soon as Android tries to run your modified apk, it'll FC. Even if that's the only change that you've made to it.
Why?
Well, it's not because you deleted the status icon line...it's because you deleted the line's 'id'
Let's have another look at the status icon line:
Code:
<ImageView
android:layout_gravity="center_vertical"
[color="red"]android:id="@id/status"[/color]
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
Some of these attributes we'll discuss later, the one we're concerned with right now is 'android:id="@id/status"'
The attribute 'android:id' is used as a reference. Sometimes they just provide a reminder of what the line does, sometimes they are used by the apk's Java code.
We've deleted the reference to the status icons, but not the Java/smali code that defines which icons should be shown.
The apk will run, work out which status icons to show, can't find where they should go, report an error and Android will force the app to close.
Which is annoying.
There are three ways we can fix this and stop the status icons from showing without the app FC'ing on us:
1. We could work out what the hex reference is that's associated with that id, track it through the smali and edit the code as needed. Which is a lot of work. A lot of work.
2. We could try to make the status icons invisible by setting their height and width to 0.
Code:
<ImageView
android:layout_gravity="center_vertical"
android:id="@id/status"
android:layout_width="[color="red"]0.0dip[/color]"
android:layout_height="[color="red"]0.0dip[/color]"
/>
This works but isn't ideal. Android is still using processing time and power to show those icons, we just can't see them. We're only talking about a handful of icons on the statusbar and the difference in the drain on the processor is negligible, but it's still not best practice.
3. We can change the lines 'visibility by adding a new attribute..
Code:
<ImageView
[color="red"]android:visibility="gone"[/color]
android:layout_gravity="center_vertical"
android:id="@id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
This makes Android ignore this line completely. It's not visible to us because Android just doesn't bother drawing it.
Setting the height and width to 0 isn't the best solution for hiding something but there are times when changing the visibility doesn't work. You may find lines of XML that already have 'android:visibility="gone"' in them. Some ROM's have the option to hide/show certain parts of their UI while running.
So a line with 'android:visibility="gone"' can be forced to become visible. Changing the height and width to zero stops it from ever becoming visible.
If the last paragraph didn't really make sense, don't worry about it. For most of the mods you're likely to do, you can use either option 2 or option 3 to stop things from showing. It's up to you.
Basically, if you want to remove a line with an 'android:id' attribute in it..
Don't Delete It...Hide It!​
*** Some Useful Codes To Know ***​
This object of this thread is to help you understand and master XML but I'm not going to explain what every tag and attribute means.
I don't have the space nor the time to do so. There are a lot of Android XML codes available.
And I don't need to, either. Google got there first. This is a link to their developers website: http://developer.android.com/reference/packages.html. Do a search for any Android XML tag or attribute you're unsure about and you'll be given a lot of information about it from the people that created it. I visit this site nearly every day.
But there are some things I think you could do with knowing about right now. And those are LinearLayout, RelativeLayout, FrameLayout, android:layout_width and android:layout_height.
*** LinearLayout, RelativeLayout And FrameLayout ***​
In Android, a 'Layout' is a collection of tags or 'objects' arranged together in a particular manner. These are essential to get an app laid out correctly.
A 'LinearLayout' is a collection of objects laid out in a line. The first object within the Layout sits at the top or the left of that Layout. LinearLayouts can be vertical or horizontal, according to their 'androidrientation' attribute.
The second object sits underneath or to the right of that Layout.
This is a sample LinearLayout taken from my SystemUI.apk's navigation_bar.xml:
Code:
<LinearLayout android:orientation="horizontal" android:id="@id/nav_buttons" android:clipChildren="false" android:clipToPadding="false" android:layout_width="fill_parent" android:layout_height="fill_parent" android:animateLayoutChanges="true">
<View android:visibility="invisible" android:layout_width="40.0dip" android:layout_height="fill_parent" android:layout_weight="0.0" />
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@id/back" android:layout_width="@dimen/navigation_key_width" android:layout_height="fill_parent" android:src="@drawable/ic_sysbar_back" android:layout_weight="0.0" android:contentDescription="@string/accessibility_back" android:layout_marginStart="@dimen/navigation_key_outer_margin" systemui:keyCode="4" systemui:glowBackground="@drawable/ic_sysbar_highlight" />
<View android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1.0" />
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@id/home" android:layout_width="@dimen/navigation_key_width" android:layout_height="fill_parent" android:src="@drawable/ic_sysbar_home" android:layout_weight="0.0" android:contentDescription="@string/accessibility_home" systemui:keyCode="3" systemui:keyRepeat="false" systemui:glowBackground="@drawable/ic_sysbar_highlight" />
<View android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1.0" />
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@id/recent_apps" android:layout_width="@dimen/navigation_key_width" android:layout_height="fill_parent" android:src="@drawable/ic_sysbar_recent" android:layout_weight="0.0" android:contentDescription="@string/accessibility_recent" android:layout_marginEnd="@dimen/navigation_key_outer_margin" systemui:keyCode="187" systemui:glowBackground="@drawable/ic_sysbar_highlight" />
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@id/menu" android:visibility="invisible" android:layout_width="@dimen/navigation_menu_key_width" android:layout_height="fill_parent" android:src="@drawable/ic_sysbar_menu" android:layout_weight="0.0" android:contentDescription="@string/accessibility_menu" systemui:keyCode="82" systemui:glowBackground="@drawable/ic_sysbar_highlight" />
</LinearLayout>
Here the tags that display my different softkeys are arranged in a horizontal line, which looks something like this:
A 'RelativeLayout' also arranges objects in a line, but lets you put them in different places relative to each other and the Layout. There's a wonderful example of this here: http://www.mkyong.com/android/android-relativelayout-example/. This explains this sort of Layout far better than I ever could.
RelativeLayouts are very flexible, but it can get quite complicated keeping track of what's supposed to be going where.
A 'FrameLayout' arranges objects in a frame. Which doesn't explain things well.
Think of it as creating a photo frame. Every object in that FrameLayout is placed into the middle of the frame, laid on top of the object before it. FrameLayouts can be very useful if you want to put multiple objects in the same place. My rom uses a FrameLayout to overlay my data connection icons on top of my signal icons. Here's one from my signal_cluster_view.xml:
Code:
<FrameLayout android:id="@id/wifi_combo" android:layout_width="wrap_content" android:layout_height="wrap_content">
<ImageView android:layout_gravity="bottom|center" android:id="@id/wifi_signal" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<ImageView android:layout_gravity="bottom|center" android:id="@id/wifi_inout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/somc_sys_signal_wifi_activity" />
</FrameLayout>
For more detailed info on these Layouts, have a look at Google's developer site. The link is in the text above.
(There's another Layout available in Android. It's called a TableLayout but I haven't mentioned it because you'll rarely, if ever, see it when you're modding your apk's. In over two years of being a Recognized Themer, I've been asked about it once.)
*** android:layout_height And android:layout_width ***​
In the Layouts above, we had some tags inside other tags. This is known as 'nesting' and is fine as long as you remember to include the correct 'end tag'.
Code:
<FrameLayout android:id="@id/wifi_combo" android:layout_width="wrap_content" android:layout_height="wrap_content"[COLOR="Red"]>[/COLOR]
<ImageView android:layout_gravity="bottom|center" android:id="@id/wifi_signal" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<ImageView android:layout_gravity="bottom|center" android:id="@id/wifi_inout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/somc_sys_signal_wifi_activity" />
[COLOR="Red"] </FrameLayout>[/COLOR]
That '</FrameLayout>' in red is the end tag for this FrameLayout. Every line between this line and the first one are considered to be nested within the Layout.
Note that the first line, because the tag doesn't end there, finishes in a '>', not a '/>' as usual.
In programming terms, the FrameLayout in that example is considered the 'parent' and the two ImageView lines are considered the 'children'.
Let's have another look at my clock XML:
Code:
<com.android.systemui.statusbar.policy.Clock
android:textAppearance="@style/TextAppearance.StatusBar.Clock"
android:gravity="start|center"
android:id="@id/clock"
android:layout_width="[COLOR="Red"]wrap_content[/COLOR]"
android:layout_height="[COLOR="Blue"]fill_parent[/COLOR]"
android:singleLine="true"
android:paddingStart="6.0dip"
/>
This clock can be thought of as being inside a 'layout'. Not a 'Layout' with a capital, just a lower-case layout. This may seem odd, but just go with it.
Here the clock layout's height, or the 'layout_height', is set to "fill_parent". This means the clock's layout occupies a section of space on the screen the same height as the parent Layout (with a capital L). This ultimately means the clock occupies a section of space the same height as the statusbar.
This doesn't mean, the clock is the same height as the statusbar. To make the clock itself the same height, we'd have to change the size of the text. Think of it like the difference between the size of a painting and the size of its canvas..
The width of the clock, or the 'layout_width', is set to "wrap_content". This means the clocks 'layout' is exactly as wide as the content inside it. In other words, it's the exact same width as the clock itself.
It's important to know the difference between wrap_content and fill_parent and just as important to understand that these control the space an object uses, not the size of the object itself.
*** Now For The Fun Part ***​
Brain starting to hurt? I know mine is and I understand XML fairly well. (Although I should stress I'm no expert.)
Let's start putting everything I've talked about into practice, shall we? Read on to the next post to start modding!
*** How To Change The Colour Of The Status Bar Clock ***​
For our first mod, we're going to do something fairly simple. We're going to change the colour of something.
Changing the colour of the clock on the status bar may be an easy mod but it's one that can make a dramatic difference to the look of your Android device. And it serves as a nice introduction to how easy it is to mod XML.
To do this, we'll need to edit status_bar.xml inside SystemUI.apk.
If you're using a multi-sim phone, you might need to edit msim_status_bar.xml.
If you're using a non-stock rom, you might need to decompile a different apk to get the relevant XML file.
This is what the status_bar.xml looks like in stock KitKat:
Code:
<com.android.systemui.statusbar.phone.PhoneStatusBarView android:id="@+id/status_bar" android:background="@drawable/system_bar_background" android:orientation="vertical" android:focusable="true" android:descendantFocusability="afterDescendants" android:fitsSystemWindows="true"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui">
<ImageView android:id="@+id/notification_lights_out" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="match_parent" android:paddingStart="6dip" android:paddingBottom="2dip" android:src="@drawable/ic_sysbar_lights_out_dot_small" android:scaleType="center" android:visibility="gone" />
<LinearLayout android:id="@+id/status_bar_contents" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingStart="6dip" android:paddingEnd="6dip" android:orientation="horizontal" >
<LinearLayout android:id="@+id/notification_icon_area" android:layout_width="0dip" android:layout_height="match_parent" android:layout_weight="1" android:orientation="horizontal" >
<com.android.systemui.statusbar.StatusBarIconView android:id="@+id/moreIcon" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="match_parent" android:src="@drawable/stat_notify_more" android:visibility="gone" />
<com.android.systemui.statusbar.phone.IconMerger android:id="@+id/notificationIcons" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentStart="true" android:gravity="center_vertical" android:orientation="horizontal"/>
</LinearLayout>
<LinearLayout android:id="@+id/system_icon_area" android:layout_width="wrap_content" android:layout_height="match_parent" android:orientation="horizontal">
<LinearLayout android:id="@+id/statusIcons" android:layout_width="wrap_content" android:layout_height="match_parent" android:gravity="center_vertical" android:orientation="horizontal"/>
<LinearLayout android:id="@+id/signal_battery_cluster" android:layout_width="wrap_content" android:layout_height="match_parent" android:paddingStart="2dp" android:orientation="horizontal" android:gravity="center" >
<include layout="@layout/signal_cluster_view" android:id="@+id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<com.android.systemui.BatteryMeterView android:id="@+id/battery" android:layout_height="16dp" android:layout_width="10.5dp" android:layout_marginBottom="0.33dp" android:layout_marginStart="4dip" />
</LinearLayout>
<com.android.systemui.statusbar.policy.Clock android:id="@+id/clock" android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:layout_width="wrap_content" android:layout_height="match_parent" android:singleLine="true" android:paddingStart="6dip" android:gravity="center_vertical|start" />
</LinearLayout>
</LinearLayout>
<LinearLayout android:id="@+id/ticker" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingStart="6dip" android:animationCache="false" android:orientation="horizontal" >
<ImageSwitcher android:id="@+id/tickerIcon" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:layout_marginEnd="4dip" >
<com.android.systemui.statusbar.AnimatedImageView android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:scaleType="center" />
<com.android.systemui.statusbar.AnimatedImageView android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:scaleType="center" />
</ImageSwitcher>
<com.android.systemui.statusbar.phone.TickerView android:id="@+id/tickerText" android:layout_width="0dip" android:layout_weight="1" android:layout_height="wrap_content" android:paddingTop="2dip" android:paddingEnd="10dip">
<TextView android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" />
<TextView android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" />
</com.android.systemui.statusbar.phone.TickerView>
</LinearLayout>
</com.android.systemui.statusbar.phone.PhoneStatusBarView>
Here's the Gingerbread status_bar.xml:
Code:
<com.android.systemui.statusbar.StatusBarView android:orientation="vertical" android:background="@drawable/gradient" android:focusable="true" android:descendantFocusability="afterDescendants"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:orientation="horizontal" android:id="@id/icons" android:layout_width="fill_parent" android:layout_height="fill_parent">
<com.android.systemui.statusbar.IconMerger android:gravity="center_vertical" android:orientation="horizontal" android:id="@id/notificationIcons" android:paddingLeft="6.0dip" android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0" android:layout_alignParentLeft="true" />
<LinearLayout android:gravity="center_vertical" android:orientation="horizontal" android:id="@id/statusIcons" android:paddingRight="6.0dip" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_alignParentRight="true" />
<com.android.systemui.statusbar.Clock android:textAppearance="@*android:style/TextAppearance.StatusBar.Icon" android:textSize="16.0sp" android:gravity="center_vertical" android:id="@id/clock" android:paddingRight="6.0dip" android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleLine="true" />
</LinearLayout>
<LinearLayout android:orientation="horizontal" android:id="@id/ticker" android:paddingLeft="6.0dip" android:animationCache="false" android:layout_width="fill_parent" android:layout_height="fill_parent">
<ImageSwitcher android:id="@id/tickerIcon" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginRight="8.0dip">
<com.android.systemui.statusbar.AnimatedImageView android:layout_width="25.0dip" android:layout_height="25.0dip" />
<com.android.systemui.statusbar.AnimatedImageView android:layout_width="25.0dip" android:layout_height="25.0dip" />
</ImageSwitcher>
<com.android.systemui.statusbar.TickerView android:id="@id/tickerText" android:paddingTop="2.0dip" android:paddingRight="10.0dip" android:layout_width="0.0dip" android:layout_height="wrap_content" android:layout_weight="1.0">
<TextView android:textAppearance="@*android:style/TextAppearance.StatusBar.Ticker" android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="true" />
<TextView android:textAppearance="@*android:style/TextAppearance.StatusBar.Ticker" android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="true" />
</com.android.systemui.statusbar.TickerView>
</LinearLayout>
<com.android.systemui.statusbar.DateView android:textAppearance="@*android:style/TextAppearance.StatusBar.Icon" android:gravity="left|center" android:id="@id/date" android:background="#ff000000" android:paddingLeft="6.0px" android:paddingRight="6.0px" android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleLine="true" />
</com.android.systemui.statusbar.StatusBarView>
Android XML has changed a lot over the years but one thing has always stayed the same. There's always been a clock. And it's always been a piece of text.
Here's the KitKat clock line:
Code:
<com.android.systemui.statusbar.policy.Clock
android:id="@+id/clock"
android:textAppearance="@style/TextAppearance.StatusBar.Clock"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:singleLine="true"
android:paddingStart="6dip"
android:gravity="center_vertical|start"
/>
As far as Android is concerned, the clock is just a piece of text that changes every minute. And because it's text, you can use text attributes on it. One such attribute is 'android:textColor'.
Let's say we want to change our clock from the normal, boring white to a rich green. Here's what the code needs to look like:
Code:
<com.android.systemui.statusbar.policy.Clock
[color="red"] android:textColor="#ff00ff00"[/color]
android:id="@+id/clock"
android:textAppearance="@style/TextAppearance.StatusBar.Clock"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:singleLine="true"
android:paddingStart="6dip"
android:gravity="center_vertical|start"
/>
See that new attribute I've put in? This changes the colour of the text in this tag to 'ff00ff00'. Which is an ARGB code for completely opaque green.
"ARGB" is short for "Alpha Red Green Blue" and uses hexadecimal codes. Alpha, for those who might not know, is a transparency value.
So the colour I've set the clock to is "not transparent at all" - "not red at all" - "completely green" - "not blue at all".
You can use an RGB code instead, which would give us a colour '00ff00, but I prefer sticking to ARGB at all times to keep it simple. You never know when you might want to mess around with transparency!
Save, recompile, flash and your clock is now a lovely shade of green. Simple!
This attribute can be used on any text in your apk, not just the clock. You can change the colour of the date, the carrier label, your notification text...anything at all as long it's regarded as text by Android!
*** How To Change The Colour Of The Status Bar Clock - The Advanced Method ***​
Okay, so this is where it starts to get a bit more complicated.
What if there was a particular colour that you really liked, that you wanted to use for a lot of the text in your app, but which had an ARGB code that wasn't easy to remember? What if you wanted to use 'ffdb7093' (picked at random from www.color-hex.com)?
I can't remember that code and I've only just written it!
Well, the good news is that I don't have to remember it. Inside your decompiled app will be a folder called "values". Inside that, have a look at "colors.xml"
Code:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="system_bar_background_opaque">#ff000000</color>
...and so on for a few lines..
<color name="battery_text_color_critical">#ffcb2026</color>
</resources>
These are predefined colours that our app can use. So let's add a new one..
Code:
<?xml version="1.0" encoding="utf-8"?>
<resources>
[color="red"] <color name="my_colour">#ffdb7093</color>[/color]
<color name="system_bar_background_opaque">#ff000000</color>
...and so on for a few lines..
<color name="battery_text_color_critical">#ffcb2026</color>
</resources>
...change our clock XML....
Code:
<com.android.systemui.statusbar.policy.Clock
[color="red"] android:textColor="@color/my_colour"[/color]
android:id="@+id/clock"
android:textAppearance="@style/TextAppearance.StatusBar.Clock"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:singleLine="true"
android:paddingStart="6dip"
android:gravity="center_vertical|start"
/>
...add that attribute to any other text lines we want to change...
Code:
<TextView
[color="red"] android:textColor="@color/my_colour"[/color]
android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
/>
...save, recompile, flash and suddenly the clock and the notification text have changed to what color-hex.com describes as "Pale Violet Red". Nice!
Don't like it? Then you can just change the one line in colors.xml without having to worry about any other lines of XML.
*** How To Change The Colour Of The Status Bar Clock - The Even More Advanced Method ***​
When you decompiled SystemUI.apk, you may have noticed that you needed to install framework-res.apk to your PC first.
This is because SystemUI.apk uses certain resources that are contained within framework-res.apk and you need to make those available for the apk to be decompiled fully. Amongst those resources are some colours that are accessible by SystemUI.apk, as well as any other app that can access framework-res.apk.
In other words, we can add our colour to framework-res.apk and it can be used by SystemUI.apk, Phone.apk, settings.apk...and lots of other apps!
Add your colour to 'framework-res.apk/res/values/colors.xml':
Code:
<?xml version="1.0" encoding="utf-8"?>
<resources>
[color="red"] <color name="my_colour">#ffdb7093</color>[/color]
<color name="darker_gray">#ffaaaaaa</color>
...and so on for several lines..
<color name="webviewchromium_autofill_dark_divider_color">#ffc0c0c0</color>
</resources>
Then add a textColour attribute to the lines you want to change in the apk files you want to change. But use a slightly different format than before..
Code:
<com.android.systemui.statusbar.policy.Clock
[color="red"] android:textColor="@[i]android:[/i]color/my_colour"[/color]
android:id="@+id/clock"
android:textAppearance="@style/TextAppearance.StatusBar.Clock"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:singleLine="true"
android:paddingStart="6dip"
android:gravity="center_vertical|start"
/>
It'll take a while but the result is that you'll change the colour of lots of pieces of text in your rom. And, should you decide to change that colour again, all you need to do is edit one line. Very nice!
Hopefully this all makes sense. It does to me but I've been experimenting with Android XML for about three years now.. If it doesn't make any sense, feel free to ask for help. This is probably the simplest XML mod you can do and it's only going to get more complicated from here!
*** How To Put An Invisible Softkey In The Status Bar ***​
Softkeys are the buttons that are found in the navigation bar at the bottom of the screen. They are normally buttons for BACK, HOME, RECENT APPS and MENU. Although it's not unusual to find some roms with a SEARCH softkey or even some volume controls.
The status bar is the bit at the top of the screen that shows the clock, battery level, signal strength, etc.
Because phones and tablets are getting bigger and bigger, it'd be quite handy to put at least one softkey in it so we don't have to haul our finger all the way to the other end of the screen (trust me, every second counts!).
How hard is it to use something that's in one XML file (navigation_bar.xml) inside a different XML file (status_bar.xml)?
Actually, it's not hard at all!
As with a lot of things to do with the system user interface, we need to decompile our SystemUI.apk. Here's what the stock KitKat navigation_bar.xml looks like:
Code:
<com.android.systemui.statusbar.phone.NavigationBarView android:layout_height="match_parent" android:layout_width="match_parent" android:background="@drawable/system_bar_background"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui">
<FrameLayout android:id="@+id/rot0" android:layout_height="match_parent" android:layout_width="match_parent" >
<LinearLayout android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="horizontal" android:clipChildren="false" android:clipToPadding="false" android:id="@+id/nav_buttons" android:animateLayoutChanges="true" >
<View android:layout_width="40dp" android:layout_height="match_parent" android:layout_weight="0" android:visibility="invisible" />
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/back" android:layout_width="@dimen/navigation_key_width" android:layout_height="match_parent" android:src="@drawable/ic_sysbar_back" systemui:keyCode="4" android:layout_weight="0" android:scaleType="center" systemui:glowBackground="@drawable/ic_sysbar_highlight" android:contentDescription="@string/accessibility_back" />
<View android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:visibility="invisible" />
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/home" android:layout_width="@dimen/navigation_key_width" android:layout_height="match_parent" android:src="@drawable/ic_sysbar_home" systemui:keyCode="3" systemui:keyRepeat="false" android:layout_weight="0" systemui:glowBackground="@drawable/ic_sysbar_highlight" android:contentDescription="@string/accessibility_home" />
<View android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:visibility="invisible" />
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/recent_apps" android:layout_width="@dimen/navigation_key_width" android:layout_height="match_parent" android:src="@drawable/ic_sysbar_recent" android:layout_weight="0" systemui:glowBackground="@drawable/ic_sysbar_highlight" android:contentDescription="@string/accessibility_recent" />
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/menu" android:layout_width="@dimen/navigation_menu_key_width" android:layout_height="match_parent" android:src="@drawable/ic_sysbar_menu" systemui:keyCode="82" android:layout_weight="0" android:visibility="invisible" android:contentDescription="@string/accessibility_menu" systemui:glowBackground="@drawable/ic_sysbar_highlight" />
</LinearLayout>
<LinearLayout android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="horizontal" android:id="@+id/lights_out" android:visibility="gone" >
<ImageView android:layout_width="80dp" android:layout_height="match_parent" android:layout_marginStart="40dp" android:src="@drawable/ic_sysbar_lights_out_dot_small" android:scaleType="center" android:layout_weight="0" />
<View android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:visibility="invisible" />
<ImageView android:layout_width="80dp" android:layout_height="match_parent" android:src="@drawable/ic_sysbar_lights_out_dot_large" android:scaleType="center" android:layout_weight="0" />
<View android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:visibility="invisible" />
<ImageView android:layout_width="80dp" android:layout_marginEnd="40dp" android:layout_height="match_parent" android:src="@drawable/ic_sysbar_lights_out_dot_small" android:scaleType="center" android:layout_weight="0" />
</LinearLayout>
<FrameLayout android:layout_width="match_parent" android:layout_height="match_parent">
<com.android.systemui.statusbar.policy.KeyButtonView android:layout_width="80dp" android:id="@+id/search_light" android:layout_height="match_parent" android:layout_gravity="center" android:src="@drawable/search_light" android:scaleType="center" android:visibility="gone" android:contentDescription="@string/accessibility_search_light" />
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/camera_button" android:layout_height="match_parent" android:layout_width="80dp" android:layout_gravity="center_vertical|right" android:src="@drawable/ic_sysbar_camera" android:scaleType="center" android:visibility="gone" android:contentDescription="@string/accessibility_camera_button" />
</FrameLayout>
<com.android.systemui.statusbar.policy.DeadZone android:id="@+id/deadzone" android:layout_height="match_parent" android:layout_width="match_parent" systemui:minSize="@dimen/navigation_bar_deadzone_size" systemui:maxSize="@dimen/navigation_bar_deadzone_size_max" systemui:holdTime="@integer/navigation_bar_deadzone_hold" systemui:decayTime="@integer/navigation_bar_deadzone_decay" systemui:orientation="horizontal" android:layout_gravity="top" />
</FrameLayout>
<FrameLayout android:id="@+id/rot90" android:layout_height="match_parent" android:layout_width="match_parent" android:visibility="gone" android:paddingTop="0dp" >
<LinearLayout android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="vertical" android:clipChildren="false" android:clipToPadding="false" android:id="@+id/nav_buttons" android:animateLayoutChanges="true" >
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/menu" android:layout_height="40dp" android:layout_width="match_parent" android:src="@drawable/ic_sysbar_menu_land" systemui:keyCode="82" android:layout_weight="0" android:visibility="invisible" android:contentDescription="@string/accessibility_menu" systemui:glowBackground="@drawable/ic_sysbar_highlight_land" />
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/recent_apps" android:layout_height="80dp" android:layout_width="match_parent" android:src="@drawable/ic_sysbar_recent_land" android:layout_weight="0" android:contentDescription="@string/accessibility_recent" systemui:glowBackground="@drawable/ic_sysbar_highlight_land" />
<View android:layout_height="match_parent" android:layout_width="match_parent" android:layout_weight="1" android:visibility="invisible" />
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/home" android:layout_height="80dp" android:layout_width="match_parent" android:src="@drawable/ic_sysbar_home_land" systemui:keyCode="3" systemui:keyRepeat="false" android:layout_weight="0" android:contentDescription="@string/accessibility_home" systemui:glowBackground="@drawable/ic_sysbar_highlight_land" />
<View android:layout_height="match_parent" android:layout_width="match_parent" android:layout_weight="1" android:visibility="invisible" />
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/back" android:layout_height="80dp" android:layout_width="match_parent" android:src="@drawable/ic_sysbar_back_land" android:scaleType="center" systemui:keyCode="4" android:layout_weight="0" android:contentDescription="@string/accessibility_back" systemui:glowBackground="@drawable/ic_sysbar_highlight_land" />
<View android:layout_height="40dp" android:layout_width="match_parent" android:layout_weight="0" android:visibility="invisible" />
</LinearLayout>
<LinearLayout android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="vertical" android:id="@+id/lights_out" android:visibility="gone" >
<ImageView android:layout_height="80dp" android:layout_marginTop="40dp" android:layout_width="match_parent" android:src="@drawable/ic_sysbar_lights_out_dot_small" android:scaleType="center" android:layout_weight="0" />
<View android:layout_height="match_parent" android:layout_width="match_parent" android:layout_weight="1" android:visibility="invisible" />
<ImageView android:layout_height="80dp" android:layout_width="match_parent" android:src="@drawable/ic_sysbar_lights_out_dot_large" android:scaleType="center" android:layout_weight="0" />
<View android:layout_height="match_parent" android:layout_width="match_parent" android:layout_weight="1" android:visibility="invisible" />
<ImageView android:layout_height="80dp" android:layout_marginBottom="40dp" android:layout_width="match_parent" android:src="@drawable/ic_sysbar_lights_out_dot_small" android:scaleType="center" android:layout_weight="0" />
</LinearLayout>
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/search_light" android:layout_height="80dp" android:layout_width="match_parent" android:layout_gravity="center_vertical" android:src="@drawable/search_light_land" android:scaleType="center" android:visibility="gone" android:contentDescription="@string/accessibility_search_light" />
<com.android.systemui.statusbar.policy.DeadZone android:id="@+id/deadzone" android:layout_height="match_parent" android:layout_width="match_parent" systemui:minSize="@dimen/navigation_bar_deadzone_size" systemui:maxSize="@dimen/navigation_bar_deadzone_size_max" systemui:holdTime="@integer/navigation_bar_deadzone_hold" systemui:decayTime="@integer/navigation_bar_deadzone_decay" systemui:orientation="vertical" android:layout_gravity="top" />
</FrameLayout>
<View android:id="@+id/rot270" android:layout_height="match_parent" android:layout_width="match_parent" android:visibility="gone" />
</com.android.systemui.statusbar.phone.NavigationBarView>
This is relatively dense code and it can be hard to work out just what it's doing but it does all make sense. For now though, all we need is just one line. Let's say we want to put a HOME softkey in our statusbar. In that case, we just want a line with 'home' in it.
And here it is:
Code:
<com.android.systemui.statusbar.policy.KeyButtonView
[color="red"]android:id="@+id/home"[/color]
android:layout_width="@dimen/navigation_key_width"
android:layout_height="match_parent"
android:src="@drawable/ic_sysbar_home"
systemui:keyCode="3"
systemui:keyRepeat="false"
android:layout_weight="0"
systemui:glowBackground="@drawable/ic_sysbar_highlight"
android:contentDescription="@string/accessibility_home"
/>
We're going to put that into our status bar, so let's have a look at our status_bar.xml:
Code:
<com.android.systemui.statusbar.phone.PhoneStatusBarView android:id="@+id/status_bar" android:background="@drawable/system_bar_background" android:orientation="vertical" android:focusable="true" android:descendantFocusability="afterDescendants" android:fitsSystemWindows="true"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui">
<ImageView android:id="@+id/notification_lights_out" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="match_parent" android:paddingStart="6dip" android:paddingBottom="2dip" android:src="@drawable/ic_sysbar_lights_out_dot_small" android:scaleType="center" android:visibility="gone" />
<LinearLayout android:id="@+id/status_bar_contents" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingStart="6dip" android:paddingEnd="6dip" android:orientation="horizontal" >
<LinearLayout android:id="@+id/notification_icon_area" android:layout_width="0dip" android:layout_height="match_parent" android:layout_weight="1" android:orientation="horizontal" >
<com.android.systemui.statusbar.StatusBarIconView android:id="@+id/moreIcon" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="match_parent" android:src="@drawable/stat_notify_more" android:visibility="gone" />
<com.android.systemui.statusbar.phone.IconMerger android:id="@+id/notificationIcons" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentStart="true" android:gravity="center_vertical" android:orientation="horizontal"/>
</LinearLayout>
<LinearLayout android:id="@+id/system_icon_area" android:layout_width="wrap_content" android:layout_height="match_parent" android:orientation="horizontal">
<LinearLayout android:id="@+id/statusIcons" android:layout_width="wrap_content" android:layout_height="match_parent" android:gravity="center_vertical" android:orientation="horizontal"/>
<LinearLayout android:id="@+id/signal_battery_cluster" android:layout_width="wrap_content" android:layout_height="match_parent" android:paddingStart="2dp" android:orientation="horizontal" android:gravity="center" >
<include layout="@layout/signal_cluster_view" android:id="@+id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<com.android.systemui.BatteryMeterView android:id="@+id/battery" android:layout_height="16dp" android:layout_width="10.5dp" android:layout_marginBottom="0.33dp" android:layout_marginStart="4dip" />
</LinearLayout>
<com.android.systemui.statusbar.policy.Clock android:id="@+id/clock" android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:layout_width="wrap_content" android:layout_height="match_parent" android:singleLine="true" android:paddingStart="6dip" android:gravity="center_vertical|start" />
</LinearLayout>
</LinearLayout>
<LinearLayout android:id="@+id/ticker" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingStart="6dip" android:animationCache="false" android:orientation="horizontal" >
<ImageSwitcher android:id="@+id/tickerIcon" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:layout_marginEnd="4dip" >
<com.android.systemui.statusbar.AnimatedImageView android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:scaleType="center" />
<com.android.systemui.statusbar.AnimatedImageView android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:scaleType="center" />
</ImageSwitcher>
<com.android.systemui.statusbar.phone.TickerView android:id="@+id/tickerText" android:layout_width="0dip" android:layout_weight="1" android:layout_height="wrap_content" android:paddingTop="2dip" android:paddingEnd="10dip">
<TextView android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" />
<TextView android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" />
</com.android.systemui.statusbar.phone.TickerView>
</LinearLayout>
</com.android.systemui.statusbar.phone.PhoneStatusBarView>
Being right-handed, I might as well put my HOME softkey to the right of the clock. That way, it's as close to the right side of the status bar as possible. All I need to do is just copy and paste..
Code:
<com.android.systemui.statusbar.phone.PhoneStatusBarView android:id="@+id/status_bar" android:background="@drawable/system_bar_background" android:orientation="vertical" android:focusable="true" android:descendantFocusability="afterDescendants" android:fitsSystemWindows="true"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui">
<ImageView android:id="@+id/notification_lights_out" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="match_parent" android:paddingStart="6dip" android:paddingBottom="2dip" android:src="@drawable/ic_sysbar_lights_out_dot_small" android:scaleType="center" android:visibility="gone" />
<LinearLayout android:id="@+id/status_bar_contents" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingStart="6dip" android:paddingEnd="6dip" android:orientation="horizontal" >
<LinearLayout android:id="@+id/notification_icon_area" android:layout_width="0dip" android:layout_height="match_parent" android:layout_weight="1" android:orientation="horizontal" >
<com.android.systemui.statusbar.StatusBarIconView android:id="@+id/moreIcon" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="match_parent" android:src="@drawable/stat_notify_more" android:visibility="gone" />
<com.android.systemui.statusbar.phone.IconMerger android:id="@+id/notificationIcons" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentStart="true" android:gravity="center_vertical" android:orientation="horizontal"/>
</LinearLayout>
<LinearLayout android:id="@+id/system_icon_area" android:layout_width="wrap_content" android:layout_height="match_parent" android:orientation="horizontal">
<LinearLayout android:id="@+id/statusIcons" android:layout_width="wrap_content" android:layout_height="match_parent" android:gravity="center_vertical" android:orientation="horizontal"/>
<LinearLayout android:id="@+id/signal_battery_cluster" android:layout_width="wrap_content" android:layout_height="match_parent" android:paddingStart="2dp" android:orientation="horizontal" android:gravity="center" >
<include layout="@layout/signal_cluster_view" android:id="@+id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<com.android.systemui.BatteryMeterView android:id="@+id/battery" android:layout_height="16dp" android:layout_width="10.5dp" android:layout_marginBottom="0.33dp" android:layout_marginStart="4dip" />
</LinearLayout>
<com.android.systemui.statusbar.policy.Clock android:id="@+id/clock" android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:layout_width="wrap_content" android:layout_height="match_parent" android:singleLine="true" android:paddingStart="6dip" android:gravity="center_vertical|start" />
[color="red"]<com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/home" android:layout_width="@dimen/navigation_key_width" android:layout_height="match_parent" android:src="@drawable/ic_sysbar_home" systemui:keyCode="3" systemui:keyRepeat="false" android:layout_weight="0" systemui:glowBackground="@drawable/ic_sysbar_highlight" android:contentDescription="@string/accessibility_home" />[/color]
</LinearLayout>
</LinearLayout>
<LinearLayout android:id="@+id/ticker" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingStart="6dip" android:animationCache="false" android:orientation="horizontal" >
<ImageSwitcher android:id="@+id/tickerIcon" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:layout_marginEnd="4dip" >
<com.android.systemui.statusbar.AnimatedImageView android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:scaleType="center" />
<com.android.systemui.statusbar.AnimatedImageView android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:scaleType="center" />
</ImageSwitcher>
<com.android.systemui.statusbar.phone.TickerView android:id="@+id/tickerText" android:layout_width="0dip" android:layout_weight="1" android:layout_height="wrap_content" android:paddingTop="2dip" android:paddingEnd="10dip">
<TextView android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" />
<TextView android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" />
</com.android.systemui.statusbar.phone.TickerView>
</LinearLayout>
</com.android.systemui.statusbar.phone.PhoneStatusBarView>
And, once I've saved, recompiled and flashed back to the phone, here's the result:
*** But That's Not Invisible, Ticklefish!! ***​
You're right, it's not. Not only is the softkey taking up space on my status bar because it's visible, but it also looks a little squashed.
We can change the icon to make it look a bit better...but we're better off doing something a little cleverer..
For this, we're going to use a RelativeLayout to put the clock and the softkey on top of each other. And we need to make a few changes to the attributes of those lines:
Code:
<RelativeLayout android:layout_width="wrap_content" android:layout_height="fill_parent">
<com.android.systemui.statusbar.policy.Clock android:layout_alignParentRight="true" android:id="@+id/clock" android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:layout_width="wrap_content" android:layout_height="match_parent" android:singleLine="true" android:paddingStart="6dip" android:gravity="center_vertical|start" />
<com.android.systemui.statusbar.policy.KeyButtonView android:layout_alignParentRight="true" android:id="@+id/home" android:layout_width="20.0dip" android:layout_height="match_parent" systemui:keyCode="3" systemui:keyRepeat="false" android:layout_weight="0" systemui:glowBackground="@drawable/ic_sysbar_highlight" android:contentDescription="@string/accessibility_home" />
</RelativeLayout>
Here's the code in full:
Code:
<com.android.systemui.statusbar.phone.PhoneStatusBarView android:id="@+id/status_bar" android:background="@drawable/system_bar_background" android:orientation="vertical" android:focusable="true" android:descendantFocusability="afterDescendants" android:fitsSystemWindows="true"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui">
<ImageView android:id="@+id/notification_lights_out" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="match_parent" android:paddingStart="6dip" android:paddingBottom="2dip" android:src="@drawable/ic_sysbar_lights_out_dot_small" android:scaleType="center" android:visibility="gone" />
<LinearLayout android:id="@+id/status_bar_contents" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingStart="6dip" android:paddingEnd="6dip" android:orientation="horizontal" >
<LinearLayout android:id="@+id/notification_icon_area" android:layout_width="0dip" android:layout_height="match_parent" android:layout_weight="1" android:orientation="horizontal" >
<com.android.systemui.statusbar.StatusBarIconView android:id="@+id/moreIcon" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="match_parent" android:src="@drawable/stat_notify_more" android:visibility="gone" />
<com.android.systemui.statusbar.phone.IconMerger android:id="@+id/notificationIcons" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentStart="true" android:gravity="center_vertical" android:orientation="horizontal"/>
</LinearLayout>
<LinearLayout android:id="@+id/system_icon_area" android:layout_width="wrap_content" android:layout_height="match_parent" android:orientation="horizontal">
<LinearLayout android:id="@+id/statusIcons" android:layout_width="wrap_content" android:layout_height="match_parent" android:gravity="center_vertical" android:orientation="horizontal"/>
<LinearLayout android:id="@+id/signal_battery_cluster" android:layout_width="wrap_content" android:layout_height="match_parent" android:paddingStart="2dp" android:orientation="horizontal" android:gravity="center" >
<include layout="@layout/signal_cluster_view" android:id="@+id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<com.android.systemui.BatteryMeterView android:id="@+id/battery" android:layout_height="16dp" android:layout_width="10.5dp" android:layout_marginBottom="0.33dp" android:layout_marginStart="4dip" />
</LinearLayout>
<RelativeLayout android:layout_width="wrap_content" android:layout_width="fill_parent">
<com.android.systemui.statusbar.policy.Clock android:layout_alignParentRight="true" android:id="@+id/clock" android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:layout_width="wrap_content" android:layout_height="match_parent" android:singleLine="true" android:paddingStart="6dip" android:gravity="center_vertical|start" />
<com.android.systemui.statusbar.policy.KeyButtonView android:layout_alignParentRight="true" android:id="@+id/home" android:layout_width="20.0dip" android:layout_height="match_parent" systemui:keyCode="3" systemui:keyRepeat="false" android:layout_weight="0" systemui:glowBackground="@drawable/ic_sysbar_highlight" android:contentDescription="@string/accessibility_home" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout android:id="@+id/ticker" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingStart="6dip" android:animationCache="false" android:orientation="horizontal" >
<ImageSwitcher android:id="@+id/tickerIcon" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:layout_marginEnd="4dip" >
<com.android.systemui.statusbar.AnimatedImageView android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:scaleType="center" />
<com.android.systemui.statusbar.AnimatedImageView android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:scaleType="center" />
</ImageSwitcher>
<com.android.systemui.statusbar.phone.TickerView android:id="@+id/tickerText" android:layout_width="0dip" android:layout_weight="1" android:layout_height="wrap_content" android:paddingTop="2dip" android:paddingEnd="10dip">
<TextView android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" />
<TextView android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" />
</com.android.systemui.statusbar.phone.TickerView>
</LinearLayout>
</com.android.systemui.statusbar.phone.PhoneStatusBarView>
I've removed the reference to the image file in the softkey line and changed the width to 20 density-independent pixels. That width may need changing, depending on your personal preference. Too big and there'll be a big gap between the clock and the battery icon. Too small and the softkey will be very hard to tap. Experiment to find the value that works for you.
By using the RelativeLayout and the 'android:layout_alignParentRight' attribute, I've ensured that the clock and the softkey occupy the same part of the status bar. Because the softkey now has no image file, it's basically invisible.
Just tap on the clock to go back to the home screen!
(You could use a FrameLayout instead of a RelativeLayout, which would be simpler. But it's worth getting used to how RelativeLayouts work, they can be very useful!)
Of course, you don't have to put the HOME softkey in your status bar. It could be the MENU softkey, the RECENT APPS softkey, even a POWER or SEARCH softkey if you know how.
Or you can have more than one in there. Or they can be visible.
It's your device, you can do what you want.
Just make sure to make a backup before you start modding though!
*** How To Center The Clock In The Status Bar...Part 1 ***​
(I first wrote about this on the 12th of July, 2012...as you might have guessed!)​
Centering the clock in the status bar is one of the most popular XML mods in xda. It may seem like it's really difficult to do, but it's actually incredibly easy.
As long as you read this post, that is...
We're going to change the status bar which is part of the System User Interface, so we need to edit status_bar.xml in SystemUI.apk.
(As in the previous post, this isn't 100% certain. If you're using a multi-sim device, you might need msim_status_bar.xml. If you're not using a stock rom, you might need to get your XML file from a different apk.)
What I'm about to show you may seem more complicated than anything else I've shown you so far, but it does make sense. As you gain more experience modding XML, it'll start to seem very simple indeed.
So this is the XML that I'm going to be using:
Code:
<?xml version="1.0" encoding="utf-8"?>
<com.android.systemui.statusbar.phone.PhoneStatusBarView android:orientation="vertical" android:background="@drawable/status_bar_background" android:focusable="true" android:descendantFocusability="afterDescendants"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui">
<LinearLayout android:orientation="horizontal" android:id="@id/icons" android:paddingLeft="6.0dip" android:paddingRight="6.0dip" android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:orientation="horizontal" android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0">
<com.android.systemui.statusbar.StatusBarIconView android:id="@id/moreIcon" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="fill_parent" android:visibility="gone" android:src="@drawable/stat_notify_more" />
<com.android.systemui.statusbar.phone.IconMerger android:orientation="horizontal" android:id="@id/notificationIcons" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_vertical" android:layout_alignParentLeft="true" />
</LinearLayout>
<LinearLayout android:orientation="horizontal" android:id="@id/statusIcons" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center_vertical" />
<ImageView android:id="@id/stat_no_sim" android:paddingLeft="4.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone" android:layout_gravity="center_vertical" />
<LinearLayout android:orientation="horizontal" android:id="@id/signal_battery_cluster" android:paddingLeft="2.0dip" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center">
<include android:id="@id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" layout="@layout/signal_cluster_view" />
<ImageView android:id="@id/battery" android:paddingLeft="8.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
<com.android.systemui.statusbar.policy.Clock android:id="@id/clock" android:paddingLeft="6.0dip" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="left|center" android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:singleLine="true" />
</LinearLayout>
<LinearLayout android:orientation="horizontal" android:id="@id/ticker" android:paddingLeft="6.0dip" android:layout_width="fill_parent" android:layout_height="fill_parent" android:animationCache="false">
<ImageSwitcher android:id="@id/tickerIcon" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:layout_marginRight="4.0dip">
<com.android.systemui.statusbar.AnimatedImageView android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:scaleType="center" />
<com.android.systemui.statusbar.AnimatedImageView android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:scaleType="center" />
</ImageSwitcher>
<com.android.systemui.statusbar.phone.TickerView android:id="@id/tickerText" android:paddingRight="10.0dip" android:layout_width="0.0dip" android:layout_height="wrap_content" android:layout_weight="1.0" android:paddingTop="2.0dip">
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker" android:singleLine="true" />
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker" android:singleLine="true" />
</com.android.systemui.statusbar.phone.TickerView>
</LinearLayout>
</com.android.systemui.statusbar.phone.PhoneStatusBarView>
This is stock Xperia Ice-Cream Sandwich XML but you can do this mod on any version of Android from Eclair to Lollipop. (And possibly Cupcake and Donut too if anybody still uses those...)
And you can do this mod on nearly any rom as well. It's that simple.
The part of this XML that we want to affect is the part that contains what we normally see on the status bar. In the code above, this is the @id/icons LinearLayout:
Code:
<LinearLayout android:orientation="horizontal" android:id="@id/icons" android:paddingLeft="6.0dip" android:paddingRight="6.0dip" android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:orientation="horizontal" android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0">
<com.android.systemui.statusbar.StatusBarIconView android:id="@id/moreIcon" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="fill_parent" android:visibility="gone" android:src="@drawable/stat_notify_more" />
<com.android.systemui.statusbar.phone.IconMerger android:orientation="horizontal" android:id="@id/notificationIcons" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_vertical" android:layout_alignParentLeft="true" />
</LinearLayout>
<LinearLayout android:orientation="horizontal" android:id="@id/statusIcons" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center_vertical" />
<ImageView android:id="@id/stat_no_sim" android:paddingLeft="4.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone" android:layout_gravity="center_vertical" />
<LinearLayout android:orientation="horizontal" android:id="@id/signal_battery_cluster" android:paddingLeft="2.0dip" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center">
<include android:id="@id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" layout="@layout/signal_cluster_view" />
<ImageView android:id="@id/battery" android:paddingLeft="8.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
<com.android.systemui.statusbar.policy.Clock android:id="@id/clock" android:paddingLeft="6.0dip" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="left|center" android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:singleLine="true" />
</LinearLayout>
The @id/ticker LinearLayout controls what is seen on the status bar when you get a notification. We don't need to worry about that...yet...
*** The Simple Method ***​
This was first pointed out to me by my good friend and very skilled developer @serajr, so big thanks to him.
The Simple Method is very simple, very quick and is very easy to do. But it does have one slight flaw which I'll mention later..
This is the clock code:
Code:
<com.android.systemui.statusbar.policy.Clock
android:id="@id/clock"
[color="red"]android:paddingLeft="6.0dip"
android:layout_width="wrap_content"[/color]
android:layout_height="fill_parent"
[color="red"]android:gravity="left|center"[/color]
android:textAppearance="@style/TextAppearance.StatusBar.Clock"
android:singleLine="true"
/>
The first part of the Simple Method is to change the width of the space this clock occupies and how it's positioned. This is done by editing the red lines like this:
Code:
<com.android.systemui.statusbar.policy.Clock
android:id="@id/clock"
[color="red"]android:layout_width="fill_parent"[/color]
android:layout_height="fill_parent"
[color="red"]android:gravity="center"[/color]
android:textAppearance="@style/TextAppearance.StatusBar.Clock"
android:singleLine="true"
/>
Then we need to move the clock line to outside this Layout. The reason for that is centering anything inside a LinearLayout is very difficult.
It's not impossible though as we'll see in the next Method.
So our @id/icons Layout now looks like this:
Code:
[COLOR=red]<com.android.systemui.statusbar.policy.Clock android:id="@id/clock" android:paddingLeft="6.0dip" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:singleLine="true" />[/COLOR]
<LinearLayout android:orientation="horizontal" android:id="@id/icons" android:paddingLeft="6.0dip" android:paddingRight="6.0dip" android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:orientation="horizontal" android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0">
<com.android.systemui.statusbar.StatusBarIconView android:id="@id/moreIcon" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="fill_parent" android:visibility="gone" android:src="@drawable/stat_notify_more" />
<com.android.systemui.statusbar.phone.IconMerger android:orientation="horizontal" android:id="@id/notificationIcons" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_vertical" android:layout_alignParentLeft="true" />
</LinearLayout>
<LinearLayout android:orientation="horizontal" android:id="@id/statusIcons" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center_vertical" />
<ImageView android:id="@id/stat_no_sim" android:paddingLeft="4.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone" android:layout_gravity="center_vertical" />
<LinearLayout android:orientation="horizontal" android:id="@id/signal_battery_cluster" android:paddingLeft="2.0dip" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center">
<include android:id="@id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" layout="@layout/signal_cluster_view" />
<ImageView android:id="@id/battery" android:paddingLeft="8.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
Our clock now occupies the whole statusbar and, because of its gravity attribute, sits in the exact middle of it.
So far so good, but there is a problem.
All the contents of the "@id/icons" LinearLayout are pushed out of the top of the screen when a notification comes in..but the clock now isn't part of that, so it won't and we get overlapping. The notification text can't be seen properly and it looks stupid.
To fix this, we need to add a background to the "@id/ticker" LinearLayout. This will cover up the clock when there's a new notification and we get no overlapping. We'll use the same background as the normal status bar, defined at the top of the xml, but you could make it anything if you want to be artistic.
So the new code looks like this:
Code:
<com.android.systemui.statusbar.policy.Clock android:id="@id/clock" android:paddingLeft="6.0dip" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:singleLine="true" />
<LinearLayout android:orientation="horizontal" android:id="@id/icons" android:paddingLeft="6.0dip" android:paddingRight="6.0dip" android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:orientation="horizontal" android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0">
<com.android.systemui.statusbar.StatusBarIconView android:id="@id/moreIcon" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="fill_parent" android:visibility="gone" android:src="@drawable/stat_notify_more" />
<com.android.systemui.statusbar.phone.IconMerger android:orientation="horizontal" android:id="@id/notificationIcons" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_vertical" android:layout_alignParentLeft="true" />
</LinearLayout>
<LinearLayout android:orientation="horizontal" android:id="@id/statusIcons" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center_vertical" />
<ImageView android:id="@id/stat_no_sim" android:paddingLeft="4.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone" android:layout_gravity="center_vertical" />
<LinearLayout android:orientation="horizontal" android:id="@id/signal_battery_cluster" android:paddingLeft="2.0dip" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center">
<include android:id="@id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" layout="@layout/signal_cluster_view" />
<ImageView android:id="@id/battery" android:paddingLeft="8.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<LinearLayout [COLOR=red]android:background="@drawable/status_bar_background"[/COLOR] android:orientation="horizontal" android:id="@id/ticker" android:paddingLeft="6.0dip" android:layout_width="fill_parent" android:layout_height="fill_parent" android:animationCache="false">
This is very quick to do but it doesn't work with a transparent statusbar, since the background would be then transparent and won't blank out the clock.
So it won't work for KitKat and Lollipop either...
Plus, if you want to be fussy, it's not quite a perfect fix as the clock doesn't actually move and the other icons do which can look a little strange. I'm a perfectionist and this always annoyed me.
So that's why there's a second Method we could use instead..
*** How To Center The Clock In The Status Bar...Part 2 ***​
So how do we fix this issue of the overlapping notifications with the Simple Method?
With the Best Method, of course!
*** The Best Method ***​
This is a bit more involved but is the very best way to center the clock.
Or anything else.
In fact, it's a brilliant way to arrange your status bar so you can move anything anywhere.
The Best Method splits the @id/icons Layout into three unique areas, making it very easy to decide what you want where.
What we do is we use this basic arrangement:
Code:
<LinearLayout android:orientation="horizontal" android:id="@id/icons" android:paddingLeft="6.0dip" android:paddingRight="6.0dip" android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:id="@+id/Status_Bar_Left_Side" android:orientation="horizontal" android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0">
[COLOR="Red"]<!-- HERE ARE ALL THE CODES FOR THE ITEMS ON THE LEFT SIDE OF THE STATUSBAR -->[/COLOR]
</LinearLayout>
[COLOR="Red"]<!-- HERE ARE ALL THE CODES FOR THE ITEMS IN THE CENTER OF THE STATUSBAR -->[/COLOR]
<RelativeLayout android:id="@+id/Status_Bar_Right_Side" android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0">
<LinearLayout android:id="@+id/Inside_Status_Bar_Right_Side" android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_alignParentRight="true">
[COLOR="red"]<!-- HERE ARE ALL THE CODES FOR THE ITEMS ON THE RIGHT SIDE OF THE STATUSBAR -->[/COLOR]
</LinearLayout>
</RelativeLayout>
</LinearLayout>
Make sense? No? Well, don't worry. There is a logic behind all this. Even if it's not obvious.
This Method basically divides the status bar into just two individual areas. Because those areas have the same 'weight' as each other, they take up exactly the same amount of space as each other. Meaning that whatever goes between those two areas, as long as it doesn't have a weight of 1 or more, will be essentially pushed into the exact center of the status bar.
So, what we do next is apply this Method to our code from above to create:
Code:
[color="red"]<LinearLayout android:orientation="horizontal" android:id="@id/icons" android:paddingLeft="6.0dip" android:paddingRight="6.0dip" android:layout_width="fill_parent" android:layout_height="fill_parent">[/color]
<LinearLayout android:id="@+id/Status_Bar_Left_Side" android:orientation="horizontal" android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0">
[color="red"]<LinearLayout android:orientation="horizontal" android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0">
<com.android.systemui.statusbar.StatusBarIconView android:id="@id/moreIcon" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="fill_parent" android:visibility="gone" android:src="@drawable/stat_notify_more" />
<com.android.systemui.statusbar.phone.IconMerger android:orientation="horizontal" android:id="@id/notificationIcons" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_vertical" android:layout_alignParentLeft="true" />
</LinearLayout>[/color]
</LinearLayout>
[color="red"]<com.android.systemui.statusbar.policy.Clock android:id="@id/clock" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center" android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:singleLine="true"/>[/color]
<RelativeLayout android:id="@+id/Status_Bar_Right_Side" android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0">
<LinearLayout android:id="@+id/Inside_Status_Bar_Right_Side" android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_alignParentRight="true">
[color="red"]<LinearLayout android:orientation="horizontal" android:id="@id/statusIcons" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center_vertical" />
<ImageView android:id="@id/stat_no_sim" android:paddingLeft="4.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone" android:layout_gravity="center_vertical" />
<LinearLayout android:orientation="horizontal" android:id="@id/signal_battery_cluster" android:paddingLeft="2.0dip" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center">
<include android:id="@id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" layout="@layout/signal_cluster_view" />
<ImageView android:id="@id/battery" android:paddingLeft="8.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>[/color]
</LinearLayout>
</RelativeLayout>
[color="red"]</LinearLayout>[/color]
The original code is in red. The only real challenge with this Method is knowing what lines to put in the @id/Status_Bar_Left_Side Layout and which lines to put in the @id/Status_Bar_Right_Side Layout. But take your time, look at the attributes (especially the @id attributes) and it should all become clear.
See? Doesn't that just look beautiful?
And so easy to do as well!
*** The Best Method...On KitKat And Lollipop ***​
When I came up with the Best Method, Google were only just getting ready to give the world Jelly Bean.
It's two years later and the XML has changed a bit. This is what the stock KitKat status_bar.xml looks like:
Code:
<com.android.systemui.statusbar.phone.PhoneStatusBarView android:id="@+id/status_bar" android:background="@drawable/system_bar_background" android:orientation="vertical" android:focusable="true" android:descendantFocusability="afterDescendants" android:fitsSystemWindows="true"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui">
<ImageView android:id="@+id/notification_lights_out" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="match_parent" android:paddingStart="6dip" android:paddingBottom="2dip" android:src="@drawable/ic_sysbar_lights_out_dot_small" android:scaleType="center" android:visibility="gone" />
<LinearLayout android:id="@+id/status_bar_contents" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingStart="6dip" android:paddingEnd="6dip" android:orientation="horizontal" >
<LinearLayout android:id="@+id/notification_icon_area" android:layout_width="0dip" android:layout_height="match_parent" android:layout_weight="1" android:orientation="horizontal" >
<com.android.systemui.statusbar.StatusBarIconView android:id="@+id/moreIcon" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="match_parent" android:src="@drawable/stat_notify_more" android:visibility="gone" />
<com.android.systemui.statusbar.phone.IconMerger android:id="@+id/notificationIcons" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentStart="true" android:gravity="center_vertical" android:orientation="horizontal"/>
</LinearLayout>
<LinearLayout android:id="@+id/system_icon_area" android:layout_width="wrap_content" android:layout_height="match_parent" android:orientation="horizontal">
<LinearLayout android:id="@+id/statusIcons" android:layout_width="wrap_content" android:layout_height="match_parent" android:gravity="center_vertical" android:orientation="horizontal"/>
<LinearLayout android:id="@+id/signal_battery_cluster" android:layout_width="wrap_content" android:layout_height="match_parent" android:paddingStart="2dp" android:orientation="horizontal" android:gravity="center" >
<include layout="@layout/signal_cluster_view" android:id="@+id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<com.android.systemui.BatteryMeterView android:id="@+id/battery" android:layout_height="16dp" android:layout_width="10.5dp" android:layout_marginBottom="0.33dp" android:layout_marginStart="4dip" />
</LinearLayout>
<com.android.systemui.statusbar.policy.Clock android:id="@+id/clock" android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:layout_width="wrap_content" android:layout_height="match_parent" android:singleLine="true" android:paddingStart="6dip" android:gravity="center_vertical|start" />
</LinearLayout>
</LinearLayout>
<LinearLayout android:id="@+id/ticker" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingStart="6dip" android:animationCache="false" android:orientation="horizontal" >
<ImageSwitcher android:id="@+id/tickerIcon" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:layout_marginEnd="4dip" >
<com.android.systemui.statusbar.AnimatedImageView android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:scaleType="center" />
<com.android.systemui.statusbar.AnimatedImageView android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:scaleType="center" />
</ImageSwitcher>
<com.android.systemui.statusbar.phone.TickerView android:id="@+id/tickerText" android:layout_width="0dip" android:layout_weight="1" android:layout_height="wrap_content" android:paddingTop="2dip" android:paddingEnd="10dip">
<TextView android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" />
<TextView android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" />
</com.android.systemui.statusbar.phone.TickerView>
</LinearLayout>
</com.android.systemui.statusbar.phone.PhoneStatusBarView>
It looks similar to the code at the top of this post but there are significant differences. The @id/icons Layout has been replaced with a @id/status_bar_contents Layout which looks a lot more complex.
But it isn't, really. We can still use the Best Method on it. And it's actually quite easy to do.
The Best Method splits the status bar into two individual areas. The @id/status_bar_contents Layout splits the status bar into two individual areas.
Half the work is done for us.
We just need to make four very simple changes..
Code:
<com.android.systemui.statusbar.phone.PhoneStatusBarView android:id="@+id/status_bar" android:background="@drawable/system_bar_background" android:orientation="vertical" android:focusable="true" android:descendantFocusability="afterDescendants" android:fitsSystemWindows="true"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui">
<ImageView android:id="@+id/notification_lights_out" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="match_parent" android:paddingStart="6dip" android:paddingBottom="2dip" android:src="@drawable/ic_sysbar_lights_out_dot_small" android:scaleType="center" android:visibility="gone" />
<LinearLayout android:id="@+id/status_bar_contents" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingStart="6dip" android:paddingEnd="6dip" android:orientation="horizontal" >
<LinearLayout android:id="@+id/notification_icon_area" android:layout_width="0dip" android:layout_height="match_parent" android:layout_weight="1" android:orientation="horizontal" >
<com.android.systemui.statusbar.StatusBarIconView android:id="@+id/moreIcon" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="match_parent" android:src="@drawable/stat_notify_more" android:visibility="gone" />
<com.android.systemui.statusbar.phone.IconMerger android:id="@+id/notificationIcons" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentStart="true" android:gravity="center_vertical" android:orientation="horizontal"/>
</LinearLayout>
[color="red"] <com.android.systemui.statusbar.policy.Clock android:id="@+id/clock" android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:layout_width="wrap_content" android:layout_height="match_parent" android:singleLine="true" android:gravity="center_vertical|start" />[/color]
<LinearLayout android:id="@+id/system_icon_area" [color="red"]android:layout_width="0dip" android:layout_weight="1"[/color] android:layout_height="match_parent" android:orientation="horizontal">
[color="red"]<View android:visibility="invisible" android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0" />[/color]
<LinearLayout android:id="@+id/statusIcons" android:layout_width="wrap_content" android:layout_height="match_parent" android:gravity="center_vertical" android:orientation="horizontal"/>
<LinearLayout android:id="@+id/signal_battery_cluster" android:layout_width="wrap_content" android:layout_height="match_parent" android:paddingStart="2dp" android:orientation="horizontal" android:gravity="center" >
<include layout="@layout/signal_cluster_view" android:id="@+id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<com.android.systemui.BatteryMeterView android:id="@+id/battery" android:layout_height="16dp" android:layout_width="10.5dp" android:layout_marginBottom="0.33dp" android:layout_marginStart="4dip" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout android:id="@+id/ticker" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingStart="6dip" android:animationCache="false" android:orientation="horizontal" >
<ImageSwitcher android:id="@+id/tickerIcon" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:layout_marginEnd="4dip" >
<com.android.systemui.statusbar.AnimatedImageView android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:scaleType="center" />
<com.android.systemui.statusbar.AnimatedImageView android:layout_width="@dimen/status_bar_icon_size" android:layout_height="@dimen/status_bar_icon_size" android:scaleType="center" />
</ImageSwitcher>
<com.android.systemui.statusbar.phone.TickerView android:id="@+id/tickerText" android:layout_width="0dip" android:layout_weight="1" android:layout_height="wrap_content" android:paddingTop="2dip" android:paddingEnd="10dip">
<TextView android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" />
<TextView android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" />
</com.android.systemui.statusbar.phone.TickerView>
</LinearLayout>
</com.android.systemui.statusbar.phone.PhoneStatusBarView>
I've highlighted three of those four changes in red. The fourth you can't see as I just deleted the androidaddingStart="6dip" attribute from the clock line, to keep the clock centered.
The View line pushes the contents of the @id/system_icon_area Layout to the far right of the screen. The contents of the other Layout are already on the far left of the screen. So what's between should be in the center..
(thanks to @bobfrantic for the picture)​
So that's KitKat, but what about Android 5.0? What about Lollipop?
Well, this is the stock Lollipop status_bar.xml:
Code:
<?xml version="1.0" encoding="utf-8"?>
<com.android.systemui.statusbar.phone.PhoneStatusBarView android:orientation="vertical" android:id="@id/status_bar" android:background="@drawable/system_bar_background" android:focusable="true" android:descendantFocusability="afterDescendants"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui">
<ImageView android:id="@id/notification_lights_out" android:paddingBottom="2.0dip" android:visibility="gone" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="fill_parent" android:src="@drawable/ic_sysbar_lights_out_dot_small" android:scaleType="center" android:paddingStart="6.0dip" />
<LinearLayout android:orientation="horizontal" android:id="@id/status_bar_contents" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingStart="6.0dip" android:paddingEnd="8.0dip">
<com.android.systemui.statusbar.AlphaOptimizedFrameLayout android:orientation="horizontal" android:id="@id/notification_icon_area" android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0">
<com.android.keyguard.AlphaOptimizedLinearLayout android:id="@id/notification_icon_area_inner" android:layout_width="fill_parent" android:layout_height="fill_parent">
<com.android.systemui.statusbar.StatusBarIconView android:id="@id/moreIcon" android:visibility="gone" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="fill_parent" android:src="@drawable/stat_notify_more" />
<com.android.systemui.statusbar.phone.IconMerger android:gravity="center_vertical" android:orientation="horizontal" android:id="@id/notificationIcons" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentStart="true" />
</com.android.keyguard.AlphaOptimizedLinearLayout>
</com.android.systemui.statusbar.AlphaOptimizedFrameLayout>
<com.android.keyguard.AlphaOptimizedLinearLayout android:orientation="horizontal" android:id="@id/system_icon_area" android:layout_width="wrap_content" android:layout_height="fill_parent">
<include layout="@layout/system_icons" />
<com.android.systemui.statusbar.policy.Clock android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:gravity="start|center" android:id="@id/clock" android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleLine="true" android:paddingStart="7.0dip" />
</com.android.keyguard.AlphaOptimizedLinearLayout>
</LinearLayout>
<ViewStub android:id="@id/ticker_stub" android:layout="@layout/status_bar_ticker" android:inflatedId="@id/ticker" android:layout_width="fill_parent" android:layout_height="fill_parent" />
</com.android.systemui.statusbar.phone.PhoneStatusBarView>
Look closely and you'll notice that the @id/status_bar_contents Layout is still just divided into two areas: @id/notification_icon_area and @id/system_icon_area.
Adding the Best Method to that shouldn't be a problem at all...
Code:
<?xml version="1.0" encoding="utf-8"?>
<com.android.systemui.statusbar.phone.PhoneStatusBarView android:orientation="vertical" android:id="@id/status_bar" android:background="@drawable/system_bar_background" android:focusable="true" android:descendantFocusability="afterDescendants"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui">
<ImageView android:id="@id/notification_lights_out" android:paddingBottom="2.0dip" android:visibility="gone" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="fill_parent" android:src="@drawable/ic_sysbar_lights_out_dot_small" android:scaleType="center" android:paddingStart="6.0dip" />
<LinearLayout android:orientation="horizontal" android:id="@id/status_bar_contents" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingStart="6.0dip" android:paddingEnd="8.0dip">
<com.android.systemui.statusbar.AlphaOptimizedFrameLayout android:orientation="horizontal" android:id="@id/notification_icon_area" android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0">
<com.android.keyguard.AlphaOptimizedLinearLayout android:id="@id/notification_icon_area_inner" android:layout_width="fill_parent" android:layout_height="fill_parent">
<com.android.systemui.statusbar.StatusBarIconView android:id="@id/moreIcon" android:visibility="gone" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="fill_parent" android:src="@drawable/stat_notify_more" />
<com.android.systemui.statusbar.phone.IconMerger android:gravity="center_vertical" android:orientation="horizontal" android:id="@id/notificationIcons" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentStart="true" />
</com.android.keyguard.AlphaOptimizedLinearLayout>
</com.android.systemui.statusbar.AlphaOptimizedFrameLayout>
<com.android.systemui.statusbar.policy.Clock android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:gravity="start|center" android:id="@id/clock" android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleLine="true" />
<com.android.keyguard.AlphaOptimizedLinearLayout android:orientation="horizontal" android:id="@id/system_icon_area" android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0" >
<View android:visibility="invisible" android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0" />
<include layout="@layout/system_icons" />
</com.android.keyguard.AlphaOptimizedLinearLayout>
</LinearLayout>
<ViewStub android:id="@id/ticker_stub" android:layout="@layout/status_bar_ticker" android:inflatedId="@id/ticker" android:layout_width="fill_parent" android:layout_height="fill_parent" />
</com.android.systemui.statusbar.phone.PhoneStatusBarView>
Now, we're nearly there but there's still work to be done.
In Lollipop, the clock on the status bar isn't shown when the device is locked. There's not much need for it when you have a bigger clock on the lockscreen anyway. But, when we move the clock to get it centered, the clock doesn't disappear. It's always visible.
To make the clock vanish when the device is locked, you'll need to do a smali mod. Have a look at this post by @S0bes to see what to do: http://forum.xda-developers.com/showpost.php?p=58460343&postcount=172
*** Using The Best Method On Xperia KitKat ***​
For their KitKat ROM's, Sony have done something a bit different with their XML. There's not enough space here for me to say what to do about it, so have a look at my post here instead: http://forum.xda-developers.com/showpost.php?p=59569708&postcount=297
*** Anything Else, Ticklefish? ***​
Nope, that's it. This is the longest post in this thread so far. And probably the hardest to follow.
So I'll let you take a break now so you can try some XML modding for yourself.
I'll be updating this thread in time with other fun mods to try. But, for now, have some fun and see what you can come up with.
If you have any questions, or need any help, feel free to ask. I'm always happy to help and I'm hoping that some of the people I've helped over the years will be prepared to help out as well.
One final thing...ALWAYS MAKE A BACKUP!!!
*** android:layout_gravity, android:gravity AND android:layout_weight ***​
Centering the clock in the previous two posts wouldn't have been possible without using two particular attributes: 'android:gravity' and 'android:layout_weight'.
In physics, weight is the result of gravity acting on mass. But this isn't physics, it's Android, so what do these attributes actually mean?
*** GRAVITY ***​
In Android, the gravity of an object changes how it's laid out in the space it occupies.
Let's have a few practical examples to better explain..
Here's a blank status bar.
Let's add a simple clock to it.
Code:
<com.android.systemui.statusbar.policy.Clock
android:id="@id/clock"
android:background="#ff33b5e5"
android:textColor="#ffffffff"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
/>
I've missed a few attributes that you'd normally find in a real XML file, just to keep it simple. But I have added an attribute that sets the background colour to Holo Blue Light. You'll see how useful that is as I continue..
Here's my status bar now.
(DISCLAIMER: This isn't a real status bar. It's just something I put together in a picture-editing program on my PC. Doing these images with a real status bar would take forever...)
Let's add a gravity attribute to get this clock centered..
Code:
<com.android.systemui.statusbar.policy.Clock
android:id="@id/clock"
[COLOR="Red"] android:gravity="center"[/COLOR]
android:background="#ff33b5e5"
android:textColor="#ffffffff"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
/>
This gives us this..
That didn't work. The android:gravity attribute changes how an object is laid out, but only in its own space. The clock is now centered in that space, but not the statusbar.
So let's expand that space.
Code:
<com.android.systemui.statusbar.policy.Clock
android:id="@id/clock"
android:background="#ff33b5e5"
android:textColor="#ffffffff"
[COLOR="Red"] android:layout_width="fill_parent"[/COLOR]
android:layout_height="fill_parent"
/>
Which looks like:
Oops, forgot that gravity attribute!
Code:
<com.android.systemui.statusbar.policy.Clock
android:id="@id/clock"
[COLOR="Red"] android:gravity="center"[/COLOR]
android:background="#ff33b5e5"
android:textColor="#ffffffff"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
Here's the result.
Better, no?
So what's the difference between android:gravity and android:layout_gravity?
Well, android:layout_gravity affects how an object is laid out, not in its own space, but in its parent Layout.
Let's try using that to center the clock:
Code:
<com.android.systemui.statusbar.policy.Clock
android:id="@id/clock"
[COLOR="Red"] android:layout_gravity="center"[/COLOR]
android:background="#ff33b5e5"
android:textColor="#ffffffff"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
/>
Here's the result:
So why didn't that work? Well, it really depends on that parent Layout.
In a LinearLayout, some of the layout_gravity attributes are ignored. This would have worked in a RelativeLayout but, as we saw in the Simple Method two posts ago, other objects can overlap the clock.
Generally when you're modding, you normally only worry about layout_gravity when using a RelativeLayout or FrameLayout.
For your reference, here's are the values you can set your gravity to. This is taken direct from Google themselves.
Google said:
top - Push object to the top of its container, not changing its size.
bottom - Push object to the bottom of its container, not changing its size.
left - Push object to the left of its container, not changing its size.
right - Push object to the right of its container, not changing its size.
center_vertical - Place object in the vertical center of its container, not changing its size.
fill_vertical - Grow the vertical size of the object if needed so it completely fills its container.
center_horizontal - Place object in the horizontal center of its container, not changing its size.
fill_horizontal - Grow the horizontal size of the object if needed so it completely fills its container.
center - Place the object in the center of its container in both the vertical and horizontal axis, not changing its size.
fill - Grow the horizontal and vertical size of the object if needed so it completely fills its container.
clip_vertical - Additional option that can be set to have the top and/or bottom edges of the child clipped to its container's bounds. The clip will be based on the vertical gravity: a top gravity will clip the bottom edge, a bottom gravity will clip the top edge, and neither will clip both edges.
clip_horizontal - Additional option that can be set to have the left and/or right edges of the child clipped to its container's bounds. The clip will be based on the horizontal gravity: a left gravity will clip the right edge, a right gravity will clip the left edge, and neither will clip both edges.
start - Push object to the beginning of its container, not changing its size.
end - Push object to the end of its container, not changing its size.
Click to expand...
Click to collapse
Most of those you'll rarely, if ever, use while modding. But it's handy to know about them!
*** WEIGHT ***​
Weight is a trickier concept to understand.
Google, on their developer website, have this to say about the layout_weight attribute:
Google said:
The weight value is a number that specifies the amount of remaining space each view should consume, relative to the amount consumed by sibling views. This works kind of like the amount of ingredients in a drink recipe: "2 parts vodka, 1 part coffee liqueur" means two-thirds of the drink is vodka. For example, if you give one view a weight of 2 and another one a weight of 1, the sum is 3, so the first view fills 2/3 of the remaining space and the second view fills the rest. If you add a third view and give it a weight of 1, then the first view (with weight of 2) now gets 1/2 the remaining space, while the remaining two each get 1/4.
Click to expand...
Click to collapse
In my opinion, this isn't the best explanation ever. It makes things too confusing. (Although it does say a lot about work practices inside Google HQ...clearly I have the wrong job!)
Let me see if I can't explain it a little bit better..
Here's our blank status bar again.
Let's say we want a notification icon and a signal icon here.
Code:
<LinearLayout
android:orientation="horizontal"
android:id="status_bar_contents"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.android.systemui.statusbar.phone.IconMerger
android:id="@id/notificationIcons"
android:background="#ff0099cc"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
/>
<ImageView
android:id="@id/mobile_signal"
android:background="#ff33b5e5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
As before, I've missed out a few attributes that you'd have in the real code, just to make things a bit simpler to read.
And, as before, I've added a background to the signal icon. This time I'm using Holo Blue Dark (I like Holo Blue...).
This makes our status bar look like this:
I'm sure you've noticed on your status bar that the notification icons are on the left and the signal icon on the right. That's easy enough to do with a RelativeLayout or a FrameLayout but, if we have too many notifications, we would be overlapping the signal icon.
So, to do this in a LinearLayout, we use layout_weight.
This attribute essentially sets the priority for the object it's attached to.
By default, an object has a layout_weight of 0 (even if there's no layout_weight attribute in the code). So, if we give an object a layout_weight of 1, Android will allocate it more space.
Let's see it in action by changing the layout_weight of our notification icons to 1:
Code:
<LinearLayout
android:orientation="horizontal"
android:id="status_bar_contents"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.android.systemui.statusbar.phone.IconMerger
android:id="@id/notificationIcons"
[COLOR="Red"] android:layout_weight="1"[/COLOR]
android:background="#ff0099cc"
android:layout_width="0.0dip"
android:layout_height="fill_parent"
/>
<ImageView
android:id="@id/mobile_signal"
android:background="#ff33b5e5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
Android now gives that object as much space in the Layout as it can, effectively pushing the signal icon to the far right.
Because the width of the notification icon object is being changed by the layout_weight, the layout_width attribute is superseded. So you should always set it to "0.0dip", this stops Android from having to waste processing power that's not needed.
Since this is only the status bar, we're not talking about a lot of power and it's doubtful you'd notice any difference in performance. But it's always good practice.
This is essentially how the standard Android status bar is set up.
Yes, there are more icons and more Layout but, at its heart, there is still a notification area with a weight of 1 pushing a status icon area with a weight of 0 to the right of the screen.
Have a look at your status_bar.xml and you'll see what I mean!
For fun, let's see what happens if we change the weight of the signal icon as well...
Code:
<LinearLayout
android:orientation="horizontal"
android:id="status_bar_contents"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.android.systemui.statusbar.phone.IconMerger
android:id="@id/notificationIcons"
[COLOR="Red"] android:layout_weight="1"[/COLOR]
android:background="#ff0099cc"
[COLOR="Red"] android:layout_width="0.0dip"[/COLOR]
android:layout_height="fill_parent"
/>
<ImageView
android:id="@id/mobile_signal"
[COLOR="Red"] android:layout_weight="1"[/COLOR]
android:background="#ff33b5e5"
[COLOR="Red"] android:layout_width="0.0dip"[/COLOR]
android:layout_height="wrap_content"
/>
</LinearLayout>
This results in:
That looks a bit stupid. But not to worry, we can use a spacer to push that signal icon back to the right of the screen again.
Code:
<LinearLayout
android:orientation="horizontal"
android:id="status_bar_contents"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.android.systemui.statusbar.phone.IconMerger
android:id="@id/notificationIcons"
android:layout_weight="1"
android:background="#ff0099cc"
android:layout_width="0.0dip"
android:layout_height="fill_parent"
/>
<LinearLayout
android:orientation="horizontal"
android:layout_weight="1"
android:layout_width="0.0dip"
android:background="#ff33b5e5"
android:layout_height="fill_parent"
>
[color="red"]<View
android:visibility="invisible"
android:layout_width="0.0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
/>[/color]
<ImageView
android:id="@id/mobile_signal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
</LinearLayout>
Here we go..
I've changed the signal icon's weight back to 0 and put it inside a LinearLayout with a View object that has a weight of 1.
The View line pushes the signal icon to the far right but has this attribute: "android:visibility="invisible"". Remember this attribute from a few posts ago? If this is set to !invisible, Android doesn't show it but still pays attention to how much space it uses. Making it the perfect spacer!
Why am I doing this? Well, look what happens if we add a clock to all this code (using a background of Holo Blue Bright this time)...
Code:
<LinearLayout
android:orientation="horizontal"
android:id="status_bar_contents"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.android.systemui.statusbar.phone.IconMerger
android:id="@id/notificationIcons"
android:layout_weight="1"
android:background="#ff0099cc"
android:layout_width="0.0dip"
android:layout_height="fill_parent"
/>
[COLOR="Red"] <com.android.systemui.statusbar.policy.Clock
android:id="@id/clock"
android:layout_gravity="center"
android:background="#00ddff"
android:textColor="#ffffffff"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
/>[/COLOR]
<LinearLayout
android:orientation="horizontal"
android:layout_weight="1"
android:layout_width="0.0dip"
android:background="#ff33b5e5"
android:layout_height="fill_parent"
>
<View
android:visibility="invisible"
android:layout_width="0.0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
<ImageView
android:id="@id/mobile_signal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
</LinearLayout>
Here it is:
Well, would you look at that? We've just centered the clock! Neat!
Let's remove those background attributes..
Code:
<LinearLayout
android:orientation="horizontal"
android:id="status_bar_contents"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.android.systemui.statusbar.phone.IconMerger
android:id="@id/notificationIcons"
android:layout_weight="1"
android:layout_width="0.0dip"
android:layout_height="fill_parent"
/>
<com.android.systemui.statusbar.policy.Clock
android:id="@id/clock"
android:layout_gravity="center"
android:textColor="#ffffffff"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
/>
<LinearLayout
android:orientation="horizontal"
android:layout_weight="1"
android:layout_width="0.0dip"
android:layout_height="fill_parent"
>
<View
android:visibility="invisible"
android:layout_width="0.0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
<ImageView
android:id="@id/mobile_signal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
</LinearLayout>
Et voilà...
Have another look at the previous two posts. Hopefully they should make a bit more sense now...
*** Do NOT Edit "public.xml"!! ***​
I've seen a lot of tutorials on xda and other forums which say, at some point, something like this:
...add these lines to public.xml..
Click to expand...
Click to collapse
I never do this, I always leave public.xml alone, and it's probably time I explained why.
First, let's take a look at what public.xml actually is and what it does.
You'll find this file in the "res\values\" folder of your decompiled apk and it looks something like this:
Code:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<public type="attr" name="type" id="0x7f010012" />
.....
<public type="drawable" name="somc_sys_wifi_signal_null" id="0x7f0201b4" />
.....
<public type="mipmap" name="ic_launcher_dreams" id="0x7f030001" />
.....
<public type="layout" name="navigation_bar_sw600dp" id="0x7f040009" />
.....
<public type="anim" name="wallpaper_recents_launch_from_launcher_exit" id="0x7f05001a" />
.....
<public type="xml" name="somc_skin_permissions" id="0x7f060000" />
.....
<public type="array" name="config_fullBatteryVibrationPattern" id="0x7f07000f" />
.....
<public type="id" name="traffic" id="0x7f0800ac" />
.....
<public type="color" name="somc_quick_settings_tabwidget_text_colors" id="0x7f090016" />
.....
<public type="bool" name="config_miniTablet" id="0x7f0a0013" />
.....
<public type="string" name="done_button" id="0x7f0b00fe" />
.....
<public type="integer" name="status_bar_config_maxNotificationIcons" id="0x7f0c0013" />
.....
<public type="dimen" name="status_bar_recents_thumbnail_top_margin" id="0x7f0d004f" />
.....
<public type="style" name="TextAppearance.StatusBar.PhoneTicker" id="0x7f0e001d" />
.....
<public type="plurals" name="status_bar_accessibility_recent_apps" id="0x7f0f0000" />
.....
<public type="menu" name="tools_popup_menu" id="0x7f100002" />
.....
</resources>
This is the public.xml from my phone's SystemUI.apk. I've had to take some of the lines out, the whole file is over 1,300 lines long!
In fact, public.xml is probably the longest XML file you'll have in your APK files. This is because it lists all the individual parts of the APK. All the images, id's, strings, colours, styles, etc.
Each of those parts is allocated an unique hexadecimal reference. These references are known as "Resource ID's". There's a very handy post on stackoverflow that details just how Resource ID's are allocated:
hackbod @ stackoverflow said:
At build time, the aapt tool collects all of the resources you have defined (though separate files or explicit definitions in files) and assigns resource IDs to them.
A resource ID is a 32 bit number of the form: PPTTNNNN. PP is the package the resource is for; TT is the type of the resource; NNNN is the name of the resource in that type. For applications resources, PP is always 0x7f.
The TT and NNNN values are assigned by aapt arbitrarily -- basically for each new type the next available number is assigned and used (starting with 1); likewise for each new name in a type, the next available number is assigned and used (starting with 1).
So if we have these resource files handled by aapt in this order:
layout/main.xml
drawable/icon.xml
layout/listitem.xml
The first type we see is "layout" so that is given TT == 1. The first name under that type is "main" so that is given NNNN == 1. The final resource ID is 0x7f010001.
Next we see "drawable" so that is given TT == 2. The first name for that type is "icon" so that gets NNNN == 1. The final resource ID is 0x7f020001.
Last we see another "layout" which has TT == 1 as before. This has a new name "listitem" so that gets the next value NNNN == 2. The final resource ID is 0x7f010002.
Note that aapt by default makes no attempt to keep these identifiers the same between builds. Each time the resources change, they can all get new identifiers.
Click to expand...
Click to collapse
(You can find the original post here: http://stackoverflow.com/questions/6517151/how-does-the-mapping-between-android-resources-and-resources-id-work/6646113#6646113)
Resource ID's are used in the Java side of the app. Although every part of an APK gets a resource ID allocated to it, not every resource ID is used in the Java.
Here's the line of XML that displays my status bar clock:
Code:
<com.android.systemui.statusbar.policy.Clock
android:textAppearance= [user=220439]@st[/user]yle/TextAppearance.StatusBar.Clock"
android:gravity="start|center"
[color="red"]android:id="@id/clock"[/color]
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:singleLine="true"
android:paddingStart="6.0dip" />
This is the line in my public.xml that assigns a resource ID to "@id/clock":
Code:
<public type="id" name="clock" id="[color="red"]0x7f08002d[/color]" />
And this is a little snippet of smali code that uses that resource ID:
Code:
iget-object v1, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mStatusBarView:Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;
const v2, [color="red"]0x7f08002d[/color]
invoke-virtual {v1, v2}, Landroid/view/View;->findViewById(I)Landroid/view/View;
move-result-object v1
invoke-virtual {v1}, Landroid/view/View;->getWidth()I
move-result v1
add-int/2addr v0, v1
So what's the problem with adding lines to public.xml? Well, there's actually three problems..
It's very time-consuming. For everything that you're adding to public.xml, you have to work out what the next available hexadecimal reference is. The resource ID's aren't always in numerical order so you might have to search for the number you want to use to make sure it's not already taken.
And, if you've got more than one or two lines to add, it's a lot of typing.
It's easy to get wrong. Even if you're adding resource ID's that aren't already taken, you still might get a compiling error saying that the number's too high, or something similar. Which means you have to go back into public.xml, work out another hexadecimal number and try that one. Which takes even more time.
And the main problem....apktool will automatically do it for you anyway! Apktool uses a piece of software called "aapt".
Sound familiar? It should. Remember that quote from earlier?
hackbod @ stackoverflow...again said:
At build time, the aapt tool collects all of the resources you have defined (though separate files or explicit definitions in files) and assigns resource IDs to them.
Click to expand...
Click to collapse
That's right. If you add lines to public.xml, all you're doing is something that would happen when you recompile anyway.
Of course, if you want to waste time and effort doing something completely unnecessary, that's your decision...
*** Don't DELETE "public.xml" Either!! ***​
I've seen more than a few posts suggest deleting public.xml, normally if people are having difficulty getting the new resource ID's right.
Hopefully by now, you can see why this isn't necessary but it can also cause your app to crash!
The trouble is that you can't guarantee that the new resource ID's will be the same as the old ones..
hackbod @ stackoverflow...yet again said:
Note that aapt by default makes no attempt to keep these identifiers the same between builds. Each time the resources change, they can all get new identifiers.
Click to expand...
Click to collapse
Admittedly, this quote is talking about compiling brand new APK files but the point remains. Remember this line of code from earlier?
Code:
<public type="id" name="clock" id="[color="red"]0x7f08002d[/color]" />
If I delete public.xml and recompile my APK, the file will be remade but it's possible that this line will change..
Code:
<public type="id" name="clock" id="[color="blue"]0x7f08002e[/color]" />
..but the line in the smali won't.
Code:
const v2, [color="red"]0x7f08002d[/color]
So the new app will run, try to display the clock, can't find it and Android will force the app to close.
Whoops.
So, to summarise, if you spot a tutorial or a mod that tells you to edit public.xml.....don't. You never need to.
*** How To Add Seconds To The Clock ***
*** And Display The Date In Any Format You Want ***​
(If you're reading this, ignore this post. I'm busy writing it right now..)
******* reserved *******
1st one!!
Great tuts as always... Keep rocking bro!! \m/
SeCoNd! TY for the Tutorial. I always enjoy reading these type of tuts.
lts perfectly like always.
Special thanks Ticklefish
Thanx Ticklefish,
Awesome tuts..... Especially the difference between fill parent and wrap content
Sent from my GT-S6802 using XDA Free mobile app
As always Awesome Tutorials! I keep getting drawn back. Subscribed!
Ticklefish said:
****** reserved ******
Click to expand...
Click to collapse
Hey man thanks for all your helping out the community.
Here is a little trick i learned today to remove am/pm from clock in status bar on some older roms before 4.2 and on ones that dont have the traditional smali edit because the smali is different then the one with a static const that can be changed.
it took me hours and hours to find this, i read about 20 different threads on remove am/pm but none worked for my rom.
what threw me off was that mostly everything for the statusbar is in SystemUI.apk but after i gave up with that i decided to poke around framework-res.apk for a while just because i dont like to give up on things.
Here's what i found in framework-res.apk/res/values/strings.xml
Note:this version is already edited.
Code:
<string name="am">a</string>
<string name="pm">p</string>
<string name="yesterday">Yesterday</string>
<string name="today">Today</string>
<string name="tomorrow">Tomorrow</string>
<string name="hour_minute_24" formatted="false">%H:%M</string>
<string name="hour_minute_ampm" formatted="false">%-l:%M</string>
<string name="hour_minute_cap_ampm" formatted="false">%-l:%M</string>
<string name="twelve_hour_time_format">h:mm</string>
<string name="twenty_four_hour_time_format">HH:mm</string>
<string name="numeric_date" formatted="false">%-m/%-e/%Y</string>
<string name="numeric_date_format">M/d/yyyy</string>
<string name="numeric_date_template" formatted="false">%s/%s/%s</string>
<string name="month_day_year" formatted="false">%B %-e, %Y</string>
<string name="time_of_day" formatted="false">%-l:%M:%S %p</string>
<string name="date_and_time" formatted="false">%b %-e, %Y, %-l:%M:%S %p</string>
<string name="date_time">%1$s, %2$s</string>
<string name="time_date">%1$s, %3$s</string>
this seemed to be what i was looking for so i started playing around with it; it's pretty obvious that the %p is the am/pm tag, but when i removed it from all the ones that looked relevant to the clock... nothing happened... dang.
so i gave up on that and went back to looking for smali edits, but then i thought to myself in a eureka moment... most strings are defined inside their language folder, not values/
so i navigated to /framework-res.apk/res/values-en-rUS/strings.xml
i changed the same values and bam it worked. I am pretty sure u can also customize how the dates and days of the week show up in this folder too.
for my rom i'm pretty sure it was this value that removed the am/pm from the status bar.
/values-en-rUS/strings.xml
line 86: <string name="hour_minute_cap_ampm" formatted="false">%-l:%M%^p</string>
changed to:
<string name="hour_minute_cap_ampm" formatted="false">%-l:%M</string>
but if you aren't sure you can just exhaustively find all the strings.xml in your apk, and romove the %p and %^p from them, i'm pretty sure the second one (%^p) is upper case am/pm but not positive.
that's why i assumed it was line 86 because on mine the am pm was uppercase in the statusbar and its only logical that the ^ arrow up symbol defines uppercase PM. on mine i removed them all because i didn't wanna edit the file, pack the apk, flash it etc more than once when i didn't have to.
tested on LG stock rom 4.0.4 (p930) on this rom you don't even need to touch systemUI.apk to remove am/pm =D
this link also has another way to change the date format in the status bar that works on this rom also : http://forum.xda-developers.com/gal...-statusbar-center-t1491887/page6#post56622730 (post #26)
i removed my name from the screenshot that's why it's not centered. (at the bottom by the expanded handle) And yes that is an ICS rom even though it doesn't look like it (made alot of mods lol)
KronicSkillz said:
Hey man thanks for all your helping out the community.
Here is a little trick i learned today to remove am/pm from clock in status bar on some older roms before 4.2 and on ones that dont have the traditional smali edit because the smali is different then the one with a static const that can be changed.
it took me hours and hours to find this, i read about 20 different threads on remove am/pm but none worked for my rom.
what threw me off was that mostly everything for the statusbar is in SystemUI.apk but after i gave up with that i decided to poke around framework-res.apk for a while just because i dont like to give up on things.
Here's what i found in framework-res.apk/res/values/strings.xml
Note:this version is already edited.
Code:
<string name="am">a</string>
<string name="pm">p</string>
<string name="yesterday">Yesterday</string>
<string name="today">Today</string>
<string name="tomorrow">Tomorrow</string>
<string name="hour_minute_24" formatted="false">%H:%M</string>
<string name="hour_minute_ampm" formatted="false">%-l:%M</string>
<string name="hour_minute_cap_ampm" formatted="false">%-l:%M</string>
<string name="twelve_hour_time_format">h:mm</string>
<string name="twenty_four_hour_time_format">HH:mm</string>
<string name="numeric_date" formatted="false">%-m/%-e/%Y</string>
<string name="numeric_date_format">M/d/yyyy</string>
<string name="numeric_date_template" formatted="false">%s/%s/%s</string>
<string name="month_day_year" formatted="false">%B %-e, %Y</string>
<string name="time_of_day" formatted="false">%-l:%M:%S %p</string>
<string name="date_and_time" formatted="false">%b %-e, %Y, %-l:%M:%S %p</string>
<string name="date_time">%1$s, %2$s</string>
<string name="time_date">%1$s, %3$s</string>
this seemed to be what i was looking for so i started playing around with it; it's pretty obvious that the %p is the am/pm tag, but when i removed it from all the ones that looked relevant to the clock... nothing happened... dang.
so i gave up on that and went back to looking for smali edits, but then i thought to myself in a eureka moment... most strings are defined inside their language folder, not values/
so i navigated to /framework-res.apk/res/values-en-rUS/strings.xml
i changed the same values and bam it worked. I am pretty sure u can also customize how the dates and days of the week show up in this folder too.
for my rom i'm pretty sure it was this value that removed the am/pm from the status bar.
/values-en-rUS/strings.xml
line 86: <string name="hour_minute_cap_ampm" formatted="false">%-l:%M%^p</string>
changed to:
<string name="hour_minute_cap_ampm" formatted="false">%-l:%M</string>
but if you aren't sure you can just exhaustively find all the strings.xml in your apk, and romove the %p and %^p from them, i'm pretty sure the second one (%^p) is upper case am/pm but not positive.
that's why i assumed it was line 86 because on mine the am pm was uppercase in the statusbar and its only logical that the ^ arrow up symbol defines uppercase PM. on mine i removed them all because i didn't wanna edit the file, pack the apk, flash it etc more than once when i didn't have to.
tested on LG stock rom 4.0.4 (p930) on this rom you don't even need to touch systemUI.apk to remove am/pm =D
this link also has another way to change the date format in the status bar that works on this rom also : http://forum.xda-developers.com/gal...-statusbar-center-t1491887/page6#post56622730 (post #26)
i removed my name from the screenshot that's why it's not centered. (at the bottom by the expanded handle) And yes that is an ICS rom even though it doesn't look like it (made alot of mods lol)
Click to expand...
Click to collapse
That's fantastic work, well done! :highfive:
I've put a link to this post in the OP.
I've just updated the 8th post in this thread after getting a request (sort of) from @KronicSkillz.
Want to know about android:layout_gravity, android:gravity or android:layout_weight?
Then click here to find out more: http://forum.xda-developers.com/showpost.php?p=56522113&postcount=8!
I'm trying to make invisible button in legacy Xperia cm11, but the navigation bar xml is totally different, there is no @id/home, back etc, only @id/one,two. Any suggestions for me, sir.

Categories

Resources