因此,我在项目的styles.xml文件中更改了操作栏的背景。我以为我做错了什么,因为图形布局没有任何变化,但是当我将其上传到手机并运行它时,颜色就很好了。
我尝试右键单击>“使用> android版式编辑器打开”,但操作栏的颜色仍然为灰色。
如何在activity_main.xml的“图形布局”选项卡中更新预览?
供参考:我的styles.xml是:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.ActionBar.Background" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/ActionBar.Solid.StockGetter</item>
</style>
<style name="ActionBar.Solid.StockGetter" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:background">@color/OrangePeel</item>
</style>
而activity_main.xml是:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<EditText
android:id="@+id/enterStockSymbolEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:hint="@string/enter_stock_symbol"
android:inputType="text"
android:maxLength="10"
android:scrollHorizontally="true" />
<Button
android:id="@+id/enterStockSymbolButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/enterStockSymbolButton" />
</LinearLayout>
提前致谢!
最佳答案
在Eclipse的Graphical Layout视图中,选项卡顶部有一个下拉选择框,旁边有一个蓝/灰星,旁边是当前应用的主题名称。确保为预览选择了正确的主题。
关于android - 更新ActionBar的背景颜色时,为什么“图形布局” View 没有变化?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20692125/