2015-04-07 77 views
0

我在我的應用程序上有一個自定義操作欄,但位置不適合在屏幕上。操作欄稍微移動一下,因爲我無法解決這個錯誤,所以它真的很煩人。是否有我的styles.xml自定義操作欄移位

任何提示和解決方案將非常感激。

screenshot

styles.xml

<resources xmlns:android="http://schemas.android.com/apk/res/android"> 

<!-- 
    Base application theme, dependent on API level. This theme is replaced 
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices. 




--> 
<style name="AppBaseTheme" parent="Theme.AppCompat.Light"> 
    <!-- 
     Theme customizations available in newer API levels can go in 
     res/values-vXX/styles.xml, while customizations related to 
     backward-compatibility can go here. 




    --> 
</style> 

<!-- Application theme. --> 
<style name="AppTheme" parent="AppBaseTheme"> 
    <!-- All customizations that are NOT specific to a particular API-level can go here. --> 
</style> 

<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="Theme.AppCompat.Light"> 
    <item name="android:windowNoTitle">true</item> 
    <item name="windowActionBar">false</item> 
    <item name="android:windowFullscreen">true</item> 
    <item name="android:windowContentOverlay">@null</item> 
</style> 

<style name="PhotosGridView"> 
    <item name="android:horizontalSpacing">1dp</item> 
    <item name="android:numColumns">auto_fit</item> 
    <item name="android:stretchMode">columnWidth</item> 
    <item name="android:verticalSpacing">1dp</item> 
</style> 

<style name="PhotoGridLayout"> 
    <item name="android:drawSelectorOnTop">true</item> 
    <item name="android:listSelector">@drawable/photogrid_list_selector</item> 
</style> 

<style name="ThemeForHome" parent="Theme.AppCompat"> 
    <item name="homeAsUpIndicator">@drawable/menu_icon</item> 
</style> 

<style name="GeneralLabelFont"> 
    <item name="android:textSize">15sp</item> 
    <item name="android:textColor">@android:color/black</item> 
</style> 

<style name="LoginLabelFont" parent="GeneralLabelFont"> 
    <item name="android:textColor">@color/light_blue</item> 
</style> 

<style name="SubscriptionLabelFont" parent="GeneralLabelFont"> 
    <item name="android:textColor">@color/white</item> 
</style> 

<style name="LoginDialogListItemPaddings"> 
    <item name="android:paddingBottom">5dp</item> 
    <item name="android:paddingLeft">10dp</item> 
    <item name="android:paddingRight">5dp</item> 
    <item name="android:paddingTop">5dp</item> 
</style> 

<style name="Theme.Transparent" parent="AppTheme"> 
    <item name="android:windowIsTranslucent">true</item> 
    <item name="android:windowAnimationStyle">@android:style/Animation.Translucent</item> 
    <item name="android:windowBackground">@color/transparent_black</item> 
    <item name="android:colorForeground">#fff</item> 
</style> 

+0

您使用的工具欄?它似乎將左邊距添加到您添加工具欄的佈局中。 @satryaway – Pooja

+0

在這裏發佈actoinbar代碼。 – Harry

+0

public void initActionBar(View actionBar){ \t \t getSupportActionBar()。setCustomView(actionBar,new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); \t \t getSupportActionBar()。setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME); \t \t getSupportActionBar()。setDisplayHomeAsUpEnabled(false); \t \t getSupportActionBar()。setHomeButtonEnabled(true); \t \t getSupportActionBar()。setDisplayShowCustomEnabled(true); \t \t getSupportActionBar()。setDisplayShowHomeEnabled(false); getSupportActionBar()。setDisplayShowTitleEnabled(false); \t} – satryaway

回答

0

我在我的應用程序面臨的一個simliar問題。這是我怎麼設置我的自定義動作條:

final ViewGroup actionBarLayout = (ViewGroup) getLayoutInflater().inflate(
     R.layout.your_custom_action_bar_layout, 
     null); 
final ActionBar actionBar = getActionBar(); 

的下面是我的參數設置:

actionBar.setHomeButtonEnabled(false); 
actionBar.setDisplayShowHomeEnabled(false); // This line removes the space 
actionBar.setDisplayShowTitleEnabled(false); 
actionBar.setDisplayShowCustomEnabled(true); 
actionBar.setCustomView(actionBarLayout);