Android Studio的布局编辑器未能应用android:windowActionBarOverlay属性

时间:2015-02-09 15:43:19

标签: android android-layout android-studio graphical-layout-editor

我正在Android Studio中开发一个简单的应用程序,我正在真实设备上测试它(华硕zenfone 5& Android 4.4.2)。在主要活动中,我应用了这种布局:

<LinearLayout 
 xmlns:android="http://schemas.android.com/apk/res/android" 
 xmlns:tools="http://schemas.android.com/tools" 
 tools:context="madapps.mysecondapp.MainActivity"  

 android:id="@+id/activity_main" android:layout_width="match_parent"     
 android:layout_height="match_parent"
 android:paddingTop="?android:attr/actionBarSize" 
 android:orientation="horizontal" 
 android:background="@drawable/background_deathstar">

  <EditText 
      android:id="@+id/edit_message" 
      android:text="@string/message" android:layout_weight="1"     
      android:layout_width="0dp" android:layout_height="wrap_content" 
      android:hint="@string/edit_message" android:textColor="#FFF" />

  <Button android:layout_width="wrap_content"     
      android:layout_height="wrap_content" 
      android:text="@string/button_send" 
      android:onClick="sendMessage" />
</LinearLayout>

将此style.xml应用于活动

<resources>
   <style name="AppTheme" parent="android:Theme.Holo">
        <item name="android:windowActionBarOverlay">true</item>
   </style>
</resources>

我想要做的是测试不同屏幕尺寸和密度(dpi)的背景图像。 现在,问题是在我的物理设备中属性

    android:windowActionBarOverlay

已正确应用,在我的背景图片上方放置了操作栏,这在Android Studio的布局编辑器中无法正常工作,这意味着我的图片从操作栏的末尾开始。

PS。我还注意到,除了忽略windowActionBarOverlay属性之外,我的操作栏无法加载我的自定义操作按钮。我认为这两个问题有些相关。

有什么建议吗?

非常感谢

1 个答案:

答案 0 :(得分:0)

显然我不应该期望Android Studio的布局编辑器反映我在设备上看到的内容,因为它只使用了真正的Android布局系统的子集。 实际上我的操作栏是隐藏的并以编程方式显示,布局编辑器只能用作在编辑XML时拖放窗口小部件和预览布局的方法。

相关问题