0

Hi i have to developed one sample app.Here i wish to select the app name is Admin Login and gravity is center.here i have to run the app means the app name is diplayed successfully.but the gravity is not worked for me.here i wish to align the app name is center.how can i do.please give me solutions.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androidlogin.ws"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="8" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".AndroidLoginExampleActivity"
        android:label="Admin Login"  android:theme="@style/CustomTheme"   android:gravity="center">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
  </application>

  </manifest>

Edit:

  <style name="CustomWindowTitleBackground"> 
    <item name="android:background">#093f7c</item> 
    <item name="android:gravity">center</item>
 </style> 
 <style name="CustomTheme" parent="android:Theme"> 
    <item name="android:windowTitleSize">35dip</item>
    <item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
 </style>
Ram kiran Pachigolla
  • 20,897
  • 15
  • 57
  • 78
user1676640
  • 635
  • 7
  • 17
  • 37
  • 1
    just check it http://stackoverflow.com/questions/3438276/change-title-bar-text-in-android/3438352#3438352 – Ram kiran Pachigolla Oct 03 '12 at 09:59
  • A single Google search gave me this: http://stackoverflow.com/questions/8767655/application-name-center-alignment-in-android Seems to work. – stealthjong Oct 03 '12 at 10:00
  • @Christiaan de Jong: it is not worked for me yar.so ly asked question – user1676640 Oct 03 '12 at 10:05
  • @user1676640 define own style and check ram kirans comment – stealthjong Oct 03 '12 at 10:07
  • @Ramkiran here i have use below code: Here the backgroung color is set successfully.but my gravity is left only.but i wish to ser the gravity is center. – user1676640 Oct 03 '12 at 10:07

3 Answers3

1

I have checked your styles. There you specify

<item name="android:gravity">center</item>

for CustomWindowTitleBackground. Its not possible because setting gravity center means it will align in center to its parent. so there is no possibility of giving the layout width to fill_parent.

so i think you must use custom xml file and align your title

Ram kiran Pachigolla
  • 20,897
  • 15
  • 57
  • 78
0

Define a custom title style/theme. Als o check com.example.android.apis.app.CustomTitle.

Rajeev N B
  • 1,365
  • 2
  • 12
  • 24
0

Try to set gravity in AndroidLoginExampleActivity.xml file

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"   
android:id="@+id/layout" 
android:layout_width="match_parent" 
android:layout_height="wrap_content"  
android:orientation="vertical"
android:gravity ="center" >

or if you want to use gravity in sub layout then use layout_gravity in sub layout.