2015-01-03 4 views
0

Я хотел бы изменить положение названия моего приложения, чтобы оно было справа от моего значка в моей панели действий (как в приложении gmail для Android). В настоящее время приложение выглядит следующим образом:Изменить положение названия приложения в панели действий

enter image description here

Я хотел вертикальные полосы появляется слева от названия приложения. Мой текущий styles.xml является:

<resources> 
<style name="AppTheme" parent="android:Theme.Holo.Light"> 
    <item name="android:actionBarStyle">@style/ActionBarTheme</item> 
</style> 

<style name="ActionBarTheme" parent="android:Widget.Holo.Light.ActionBar.Solid.Inverse"> 
    <item name="android:background">@color/primary</item> 
    <item name="android:logo">@color/transparent</item> 
</style> 

</resources> 

и мое меню XML является:

<?xml version="1.0" encoding="utf-8"?> 
<menu xmlns:android="http://schemas.android.com/apk/res/android" > 
<item android:id="@+id/action_menu" 
     android:icon="@drawable/ic_menu_white_36dp" 
     android:title="Menu" 
     android:showAsAction="always" 
     /> 

</menu> 

ответ

0

Где ваш ic_launcher_icon или значок приложения по умолчанию? Проверьте свои чертежи, и если их там нет, сохраните их.

Тогда вы обязательно увидите заголовок Action Bar в правой части вашего приложения.

0

для этого ниже мой код надеюсь, что это будет ЛФВЭ вас ..

actionbar.setDisplayShowCustomEnabled(true); 
actionbar.setDisplayUseLogoEnabled(false); 
actionbar.setDisplayShowHomeEnabled(false); 
actionbar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); 
actionbar.setCustomView(getLayoutInflater().inflate(R.layout.actionbar_bg, null), 
      new ActionBar.LayoutParams(
        ActionBar.LayoutParams.WRAP_CONTENT, 
        ActionBar.LayoutParams.MATCH_PARENT, 
        Gravity.CENTER 
      ) 
    ); 

и создать свой собственный взгляд, то, что вы хотите использовать файл XML. ниже мой xml-

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@color/btn_bg_color"> 

<ImageButton 
    android:id="@+id/left_logo" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:padding="15dp" 
    android:visibility="gone" 
    android:contentDescription="@string/app_name" 
    android:background="@android:color/transparent" 
    android:src="@drawable/refresh_btn"/> 

<TextView 
    android:id="@+id/title" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/app_name" 
    android:textColor="@color/white_color" 
    android:textSize="18sp" 
    android:padding="5dp" 
    android:layout_centerInParent="true" 
    android:gravity="center_horizontal"/> 

    <ImageButton 
    android:id="@+id/right_logo" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:padding="15dp" 
    android:layout_alignParentRight="true" 
    android:contentDescription="@string/app_name" 
    android:background="@android:color/transparent" 
    android:src="@drawable/logout_btn"/> 
    </RelativeLayout> 
Смежные вопросы