Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to have two alignments to the application name of an android app?

I am tyring to achieve two alignments in the title of an android app. The title according to my requirement needs to have a 'name' which is left aligned and a 'version number' which is right aligned.

So far what I have tried doing is to test whether the label attribute of the application tag of the AndroidManifest.xml files accepts html, but it does not seem to :(. Also from some of the other similar questions I came to know that the style of the title could be changed using a custom theme. But this does not answer my question:

"Can we have two different alignments (say left and right), or for that case two different themes, to the parts of the application name?"

P.S: A screenshot of the desired application title is attached below.

enter image description here

like image 771
PCoder Avatar asked Nov 21 '25 07:11

PCoder


1 Answers

You can create custom title bar .. here is sample code.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(R.layout.i_main);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.i_title);

    final TextView titleLeft = (TextView) findViewById(R.id.title_left);

    final TextView titleRight = (TextView) findViewById(R.id.title_right);
    titleLeft.setText("Checker");
    titleRight.setText("Version 5.44");

}

i_title.xml

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/title_left"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="app name" />

    <TextView
        android:id="@+id/title_right"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:text="app version" />

</RelativeLayout>
like image 127
Niranj Patel Avatar answered Nov 22 '25 21:11

Niranj Patel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!