FORUMS
Remove All Ads from XDA

[Guide][Mod] Custom Text In Status Bar

3,121 posts
Thanks Meter: 2,216
 
Post Reply Email Thread
7th April 2019, 04:30 PM |#61  
Quote:
Originally Posted by Cheemaa

@[email protected] Wolf i tried this on samsung pie and it works. the only issue i am having is bringing it to the center, i read the thread and saw that i had to change it to left instead of left center and it didnt work. i even tried center and it didnt work. any clue on how to bring it to the middle? it appears in the top left.

If you can share your code, before and after you apply the mod, I can take a look.

Sent from my Sony Xperia XA1 using XDA Labs
 
 
8th April 2019, 08:41 PM |#62  
Senior Member
Thanks Meter: 19
 
More
There you go
Quote:
Originally Posted by Ticklefish

If you can share your code, before and after you apply the mod, I can take a look.

Sent from my Sony Xperia XA1 using XDA Labs

@Ticklefish

<?xml version="1.0" encoding="utf-8"?>
<com.android.systemui.statusbar.phone.PhoneStatusB arView androidrientation="vertical" android:id="@id/status_bar" android:background="@drawable/system_bar_background" android:focusable="false" android:descendantFocusability="afterDescendants" android:layout_width="fill_parent" android:layout_height="@dimen/status_bar_height" android:accessibilityPaneTitle="@string/status_bar"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui">
<FrameLayout android:id="@id/background" android:layout_width="fill_parent" android:layout_height="fill_parent" />
<LinearLayout android:gravity="center" android:layout_gravity="center" androidrientation="horizontal" android:id="@id/middle_clock_container" android:layout_width="wrap_content" android:layout_height="fill_parent" />
<FrameLayout android:id="@id/status_bar_area" android:layout_width="fill_parent" android:layout_height="fill_parent">
<TextView android:textSize="14.0dip" android:textColor="#ffffffff" android:gravity="left|center" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="@string/hello" android:singleLine="true" />
<ImageView android:id="@id/notification_lights_out" androidaddingBottom="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" androidaddingStart="@dimen/status_bar_padding_start" />
<LinearLayout androidrientation="horizontal" android:id="@id/status_bar_contents" android:layout_width="fill_parent" android:layout_height="fill_parent" androidaddingStart="@dimen/status_bar_padding_start" androidaddingEnd="@dimen/status_bar_padding_end">
<ViewStub android:id="@id/operator_name" android:layout="@layout/operator_name" android:layout_width="wrap_content" android:layout_height="fill_parent" />
<FrameLayout android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0">
<include layout="@layout/heads_up_status_bar_layout" />
<LinearLayout android:id="@id/status_bar_left_side" android:clipChildren="false" android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:gravity="center_vertical" androidrientation="horizontal" android:id="@id/left_clock_container" android:layout_width="wrap_content" android:layout_height="fill_parent">
<LinearLayout android:gravity="center" androidrientation="horizontal" android:id="@id/network_logo_image_container" android:layout_width="wrap_content" android:layout_height="fill_parent" />
<include android:layout_width="wrap_content" android:layout_height="fill_parent" layout="@layout/qs_status_bar_clock" />
</LinearLayout>
<com.android.systemui.statusbar.AlphaOptimizedFram eLayout androidrientation="horizontal" android:id="@id/notification_icon_area" android:clipChildren="false" android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0" />
</LinearLayout>
</FrameLayout>
<android.widget.Space android:gravity="center" android:id="@id/cutout_space_view" android:layout_width="0.0dip" android:layout_height="fill_parent" />
<com.android.keyguard.AlphaOptimizedLinearLayout android:gravity="end|center" androidrientation="horizontal" android:id="@id/system_icon_area" android:layout_width="wrap_content" android:layout_height="fill_parent">
<ViewStub android:id="@id/qs_knox_custom_statusbar_viewstub" android:layout="@layout/qs_knox_custom_statusbar_text" android:layout_width="wrap_content" android:layout_height="fill_parent" />
<include layout="@layout/system_icons" />
<LinearLayout android:gravity="center" androidrientation="horizontal" android:id="@id/right_clock_container" android:layout_width="wrap_content" android:layout_height="fill_parent" />
</com.android.keyguard.AlphaOptimizedLinearLayout>
</LinearLayout>
<ViewStub android:id="@id/emergency_cryptkeeper_text" android:layout="@layout/emergency_cryptkeeper_text" android:layout_width="wrap_content" android:layout_height="fill_parent" />
</FrameLayout>
</com.android.systemui.statusbar.phone.PhoneStatusBa rView>

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


~i tried android:gravity="left|center", android:gravity="left", android:gravity="center"
~i have added the string correctly in the other xml in res/values, the colored text shows fine but it does not show in the middle for some reason.


,thanks for the help @Ticklefish
The Following User Says Thank You to Cheemaa For This Useful Post: [ View ] Gift Cheemaa Ad-Free
10th April 2019, 05:50 PM |#63  
Quote:
Originally Posted by Cheemaa

@Ticklefish

~i tried android:gravity="left|center", android:gravity="left", android:gravity="center"
~i have added the string correctly in the other xml in res/values, the colored text shows fine but it does not show in the middle for some reason.


,thanks for the help @Ticklefish

This is your code:
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="false" android:descendantFocusability="afterDescendants" android:layout_width="fill_parent" android:layout_height="@dimen/status_bar_height" android:accessibilityPaneTitle="@string/status_bar"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui">
    <FrameLayout android:id="@id/background" android:layout_width="fill_parent" android:layout_height="fill_parent" />
        <LinearLayout android:gravity="center" android:layout_gravity="center" android:orientation="horizontal" android:id="@id/middle_clock_container" android:layout_width="wrap_content" android:layout_height="fill_parent" />
                <FrameLayout android:id="@id/status_bar_area" android:layout_width="fill_parent" android:layout_height="fill_parent">
                    <TextView android:textSize="14.0dip" android:textColor="#ffffffff" android:gravity="left|center" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="@string/hello" android:singleLine="true" />
                    <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="@dimen/status_bar_padding_start" />
				<LinearLayout android:orientation="horizontal" android:id="@id/status_bar_contents" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingStart="@dimen/status_bar_padding_start" android:paddingEnd="@dimen/status_bar_padding_end">
					<ViewStub android:id="@id/operator_name" android:layout="@layout/operator_name" android:layout_width="wrap_content" android:layout_height="fill_parent" />
					<FrameLayout android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0">
					<include layout="@layout/heads_up_status_bar_layout" />
					<LinearLayout android:id="@id/status_bar_left_side" android:clipChildren="false" android:layout_width="fill_parent" android:layout_height="fill_parent">
						<LinearLayout android:gravity="center_vertical" android:orientation="horizontal" android:id="@id/left_clock_container" android:layout_width="wrap_content" android:layout_height="fill_parent">
						<LinearLayout android:gravity="center" android:orientation="horizontal" android:id="@id/network_logo_image_container" android:layout_width="wrap_content" android:layout_height="fill_parent" />
						<include android:layout_width="wrap_content" android:layout_height="fill_parent" layout="@layout/qs_status_bar_clock" />
					</LinearLayout>
					<com.android.systemui.statusbar.AlphaOptimizedFrameLayout android:orientation="horizontal" android:id="@id/notification_icon_area" android:clipChildren="false" android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0" />
				</LinearLayout>
			</FrameLayout>
			<android.widget.Space android:gravity="center" android:id="@id/cutout_space_view" android:layout_width="0.0dip" android:layout_height="fill_parent" />
			<com.android.keyguard.AlphaOptimizedLinearLayout android:gravity="end|center" android:orientation="horizontal" android:id="@id/system_icon_area" android:layout_width="wrap_content" android:layout_height="fill_parent">
				<ViewStub android:id="@id/qs_knox_custom_statusbar_viewstub" android:layout="@layout/qs_knox_custom_statusbar_text" android:layout_width="wrap_content" android:layout_height="fill_parent" />
				<include layout="@layout/system_icons" />
				<LinearLayout android:gravity="center" android:orientation="horizontal" android:id="@id/right_clock_container" android:layout_width="wrap_content" android:layout_height="fill_parent" />
			</com.android.keyguard.AlphaOptimizedLinearLayout>
		</LinearLayout>
		<ViewStub android:id="@id/emergency_cryptkeeper_text" android:layout="@layout/emergency_cryptkeeper_text" android:layout_width="wrap_content" android:layout_height="fill_parent" />
	</FrameLayout>
</com.android.systemui.statusbar.phone.PhoneStatusBarView>
I've added some CODE tags, highlighted the line you want to center, and I've done my best to remove those smilies. It makes the code a lot more readable.

You can center your text in the Layout it's in but that won't help you any. Currently it's inside the "@id/status_bar_area" FrameLayout, which displays everything on the left side of the status bar. You need the text centered in the "@id/background" FrameLayout, which displays the entire status bar.
The easiest way to do this is to move your text line to inside that Layout and add an attribute to center it:
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="false" android:descendantFocusability="afterDescendants" android:layout_width="fill_parent" android:layout_height="@dimen/status_bar_height" android:accessibilityPaneTitle="@string/status_bar"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui">
	<FrameLayout android:id="@id/background" android:layout_width="fill_parent" android:layout_height="fill_parent" />
		<TextView android:textSize="14.0dip" android:textColor="#ffffffff" android:layout_gravity="center" android:gravity="center" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="@string/hello" android:singleLine="true" />
		<LinearLayout android:gravity="center" android:layout_gravity="center" android:orientation="horizontal" android:id="@id/middle_clock_container" android:layout_width="wrap_content" android:layout_height="fill_parent" />
			<FrameLayout android:id="@id/status_bar_area" android:layout_width="fill_parent" android:layout_height="fill_parent">
....
....
This is a bit of a cheat as this won't stop icons from overlapping the text though. If you find that's a problem, we should be able to fix it but that's going to involve a bit more thinking as we'll need to start messing about with layout_weights..
18th April 2019, 09:41 AM |#64  
Bewildered Wolf's Avatar
OP Recognized Contributor
Flag NEW DELHI
Thanks Meter: 2,216
 
More
Quote:
Originally Posted by Cheemaa

@Ticklefish @Bewildered Wolf i tried this on samsung pie and it works. the only issue i am having is bringing it to the center, i read the thread and saw that i had to change it to left instead of left center and it didnt work. i even tried center and it didnt work. any clue on how to bring it to the middle? it appears in the top left.

No mate. No idea about samsung.
Post Reply Subscribe to Thread

Tags
android, custom text in status bar, easy, guide, status bar

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes