2012-11-05 23 views
3

我打算在android應用程序的標題中實現兩個對齊。根據我的要求,標題需要有一個左對齊的「名稱」和右對齊的「版本號」。是否有可能有兩個對齊android應用程序的應用程序名稱?

到目前爲止,我嘗試過的方法是測試AndroidManifest.xml文件的應用標籤的標籤屬性是否接受html,但它似乎不是:(還有一些其他類似問題要知道,標題樣式可以使用自定義主題來改變,但是這並沒有回答我的問題:

「我們可以有兩種不同的路線(比如左,右),或這種情況下,兩個不同主題,到應用程序名稱的部分?「

PS:所需應用程序的屏幕截圖標題附在下面。

enter image description here

回答

2

您可以創建自定義標題欄.. 這裏是示例代碼。

@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> 
+0

感謝您的答覆CapDroid。 – PCoder

+0

@CoderaPurpa歡迎:) –

相關問題