gpt4 book ai didi

android - 如何修复在 Nexus 设备中出现移动的导航栏?

转载 作者:行者123 更新时间:2023-11-29 17:53:32 26 4
gpt4 key购买 nike

我的应用顶部有一个导航栏。如果 galaxy/htc 设备如下所示,它看起来很好: enter image description here然而,在 nexus 设备中,它似乎有如下变化,不知道为什么:

enter image description here这是我的相同代码:(actionbar.xml):

   <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:foo="http://schemas.android.com/apk/res/com.justin.abc"
android:id="@+id/title_information_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#27272b"
android:fillViewport="true" >

<com.justin.abc.utils.FontTextView
android:id="@+id/actionbar_title"
android:layout_width="wrap_content"
android:layout_height="@dimen/actionbar_title_height"
android:layout_marginTop="@dimen/actionbar_title_topmargin"
android:layout_marginLeft="@dimen/common_left_padding"
android:text="@string/title_about"
foo:customFont="proxima-nova-regular-Regular.ttf"


android:textColor="@color/white"
android:textSize="@dimen/actionbar_title" />

<Button
android:id="@+id/button_done"
android:layout_width="wrap_content"
android:layout_height="@dimen/done_button_height"
android:layout_marginTop="@dimen/done_button_topmargin"
android:layout_alignParentRight="true"
android:layout_marginLeft="@dimen/done_button_leftmargin"
android:layout_marginRight="@dimen/done_button_rightmargin"
android:background="@drawable/done_cancel_button"
android:text="@string/menu_done"
android:textColor="@drawable/done_button_text"
android:textSize="@dimen/button_text" />


<View
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_marginTop="@dimen/actionbar_view_margintop"
android:background="@color/black"
android:visibility="visible" />

</RelativeLayout>

有什么线索可以解决这个问题,让它在所有设备上都能正常工作吗?谢谢!

这是关联的主题:

<style name="AppTheme" parent="@style/Theme.Sherlock"></style>

<style name="AppTheme.NoActionBar" parent="@style/Theme.Sherlock.NoActionBar"></style>

<style name="AppBaseTheme.NoActionBar" parent="AppTheme.NoActionBar"></style>

<!-- Although this is doing exactly what AppBaseTheme is doing,
it fixes the initialization display of the icon being truncated -->
<style name="ABTheme" parent="AppTheme">
<item name="homeAsUpIndicator">@null</item>
<item name="selectableItemBackground">@drawable/btn_selector_home_icon</item>
</style>

<style name="AppBaseTheme" parent="AppTheme">
<item name="homeAsUpIndicator">@null</item>
<item name="selectableItemBackground">@drawable/btn_selector_home_icon</item>
<item name="android:listViewStyle">@style/ListViewAppTheme</item>

<item name="android:listViewWhiteStyle">@style/ListViewAppTheme.White</item>

<item name="android:spinnerItemStyle">@style/SpinnerItemAppTheme</item>
</style>

<style name="ListViewAppTheme" parent="android:Widget.ListView">
<item name="android:listSelector">@drawable/list_selector_holo_light</item>
</style>

<style name="ListViewAppTheme.White" parent="android:Widget.ListView.White">
<item name="android:listSelector">@drawable/list_selector_holo_light</item>
</style>

<style name="SpinnerItemAppTheme" parent="android:TextAppearance.Widget.TextView.SpinnerItem">
<item name="android:textColor">#000000</item>
</style>
<style name="abc.TextView" parent="android:Widget.Holo.TextView"></style>

<style name="T1UserContactCountry">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#cccccc</item>
<item name="android:textSize">@dimen/title</item>
<item name="android:paddingLeft">@dimen/common_left_padding</item>
<item name="android:layout_gravity">left</item>
</style>
<style name="T1UserContactPhone">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">@color/abs__holo_blue_light</item>
<item name="android:textSize">@dimen/title</item>
<item name="android:onClick">onPhoneNumberClicked</item>
<item name="android:paddingRight">@dimen/common_right_padding</item>
<item name="android:layout_gravity">right</item>
<item name="android:clickable">true</item>
</style>
<style name="T1TableRowSeparator">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:paddingTop">10dp</item>
<item name="android:paddingBottom">10dp</item>
</style>
<style name="T1ViewSeparator">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">2dp</item>
<item name="android:background">@color/header_grey</item>
<item name="android:layout_span">2</item>
</style>

<style name="abc.TextView.ListsTextView">
<item name="android:ellipsize">end</item>
<item name="android:gravity">right</item>
<item name="android:singleLine">true</item>
<item name="android:background">@android:color/transparent</item>
</style>

<style name="abc.TextView.ListsTextView.Header">
<item name="android:paddingTop">2dp</item>
<item name="android:textSize">15sp</item>
<item name="android:background">@android:color/transparent</item>
</style>
<style name="CustomTheme">
<item name="android:windowBackground">@color/custom_theme_color</item>
<item name="android:colorBackground">@color/custom_theme_color</item>
</style>
<style name="abc.TextView.ListsTextView.Value">
<item name="android:textSize">15sp</item>
<item name="android:background">@android:color/transparent</item>
</style>

<style name="abc.TextView.NavigationItem">
<item name="android:clickable">true</item>
<item name="android:padding">3dp</item>
<item name="android:textSize">20sp</item>
<item name="android:background">@color/black</item>
</style>

<style name="search_autosuggest_header" parent="android:Widget.Holo.TextView">
<item name="android:paddingBottom">5dp</item>
<item name="android:paddingLeft">3dp</item>
<item name="android:textSize">16sp</item>
<item name="android:textColor">@color/search_autosuggest_header_text</item>
<item name="android:background">@drawable/background_search_auto_suggest_header</item>
<item name="android:textStyle">bold</item>
</style>

<style name="abc.TextView.Preferences">
<item name="android:padding">8dp</item>
</style>

<style name="abc.TextView.Preferences.Title">
<item name="android:background">@color/black</item>
<item name="android:textColor">@color/background_preferences_item</item>
</style>

<style name="abc.TextView.Preferences.Item">
<item name="android:background">@color/background_preferences_item</item>
<item name="android:textColor">@color/background_preferences_title</item>
</style>

<style name="abc.TextView.Preferences.Item.clickable">
<item name="android:background">@drawable/background_preferences_layout_selector</item>
<item name="android:textColor">@color/background_preferences_title</item>
</style>

<style name="abc.Button.Toggle" parent="android:Widget.Holo.Button.Toggle">
<item name="android:button">@null</item>
<item name="android:textOff"></item>
<item name="android:textOn"></item>
<item name="android:background">@drawable/toggle_selector_abc</item>
</style>

<style name="LoginEditText" parent="@android:style/Widget.EditText">
<item name="@android:textColor">@color/textbox_hint</item>
<item name="@android:textSize">16sp</item>
<item name="@android:maxLines">1</item>
<item name="@android:fontFamily">Roboto-Regular</item>
</style>

<style name="MenuDialogAnimation">
<item name="android:windowEnterAnimation">@anim/grow_from_topright_to_bottomleft</item>
<item name="android:windowExitAnimation">@anim/shrink_from_bottomleft_to_topright</item>
</style>

<style name="MenuDialogAnimationLeft">
<item name="android:windowEnterAnimation">@anim/grow_from_topleft_to_bottomright</item>
<item name="android:windowExitAnimation">@anim/shrink_from_bottomright_to_topleft</item>
</style>

<style name="BriefcaseMenuDialogAnimation">
<item name="android:windowEnterAnimation">@android:anim/fade_in</item>
<item name="android:windowExitAnimation">@android:anim/fade_out</item>
</style>
<style name="ButtonText">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#ffffff</item>
<item name="android:gravity">center</item>
<item name="android:layout_margin">3dp</item>
<item name="android:textSize">30dp</item>
<item name="android:shadowColor">#000000</item>
<item name="android:shadowDx">1</item>
<item name="android:shadowDy">1</item>
<item name="android:shadowRadius">2</item>
<item name="android:paddingLeft">15dp</item>
<item name="android:paddingRight">15dp</item>
</style>
<style name="Divider">
<item name="android:divider">@drawable/divider</item>
<item name="android:dividerHeight">1px</item>

</style>

<style name="related_buttons" parent="android:Widget.Holo.TextView">
<item name="android:clickable">true</item>
<item name="android:gravity">center_vertical|left</item>
<item name="android:layout_marginBottom">3dp</item>
<item name="android:layout_marginTop">3dp</item>
<item name="android:paddingLeft">12dp</item>
<item name="android:paddingRight">12dp</item>
<item name="android:visibility">gone</item>
<item name="android:drawableRight">@drawable/arrow_chevron_selector</item>
</style>

在我的 list 中,我引用它如下:

 <application
android:name=".abcApplication"
android:allowBackup="true"
android:icon="@drawable/abc_launcher"
android:label="@string/app_long_name"
android:theme="@style/ABTheme" android:debuggable="false">

这是我的java代码:

public void manageActionBar() {
final ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(R.layout.actionbar_no_button);
getSupportActionBar().setDisplayShowHomeEnabled(false);
final TextView titleView = (TextView) actionBar.getCustomView().findViewById(R.id.actionbar_title);
titleView.setText(R.string.personal);
}

最佳答案

这不起作用的原因是因为这不是您自定义 Action Bar 的方式, 我建议阅读如何自定义 Action Bar here .
你想要做的基本上是定义一个 theme对于您的应用程序,正如您在评论中所述,您希望根据您的项目要求更改外观。

这是我在上面链接的文章中的示例:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="@style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<item name="android:actionBarTabTextStyle">@style/TabTextStyle</item>
<item name="android:actionMenuTextColor">@color/actionbar_text</item>

<!-- Support library compatibility -->
<item name="actionBarStyle">@style/MyActionBar</item>
<item name="actionBarTabTextStyle">@style/TabTextStyle</item>
<item name="actionMenuTextColor">@color/actionbar_text</item>
</style>

<!-- general styles for the action bar -->
<style name="MyActionBar"
parent="@style/Widget.AppCompat.ActionBar">
<item name="android:titleTextStyle">@style/TitleTextStyle</item>
<item name="android:background">@drawable/actionbar_background</item>
<item name="android:backgroundStacked">@drawable/actionbar_background</item>
<item name="android:backgroundSplit">@drawable/actionbar_background</item>

<!-- Support library compatibility -->
<item name="titleTextStyle">@style/TitleTextStyle</item>
<item name="background">@drawable/actionbar_background</item>
<item name="backgroundStacked">@drawable/actionbar_background</item>
<item name="backgroundSplit">@drawable/actionbar_background</item>
</style>

<!-- action bar title text -->
<style name="TitleTextStyle"
parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/actionbar_text</item>
</style>

<!-- action bar tab text -->
<style name="TabTextStyle"
parent="@style/Widget.AppCompat.ActionBar.TabText">
<item name="android:textColor">@color/actionbar_text</item>
</style>
</resources>

之后,您可以自定义Action Bar 的外观,使其看起来就像您想要的那样(确保您以正确的方式设置颜色)。

关于android - 如何修复在 Nexus 设备中出现移动的导航栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21285968/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com