You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Studio预览窗口隐藏求助:更新后仍无法显示

Fixing Hidden Preview Window in Android Studio (API 22)

Hey there, I’ve run into this exact preview window issue before—total pain when you can’t visualize your layout without running the app. Let’s go through some tried-and-tested fixes that should get it back up and running:

  • Double-check the editor view toggle
    When you’re editing your XML layout file, look at the top-right corner of the editor panel. You should see three options: Code, Split, and Design. If you’re stuck on Code only, click Split or Design to bring the preview back. Sometimes it’s just accidentally toggled off without you noticing.

  • Invalidate caches and restart Android Studio
    Corrupted cache files are a common culprit here. Head to File > Invalidate Caches..., then select Invalidate and Restart. Let Studio fully reboot—this clears out wonky temporary files that might be blocking the preview.

  • Verify layout compatibility with API 22
    Since you’re targeting API 22, make sure your layout isn’t using components or attributes that were introduced in newer APIs. For example:

    • Replace modern Material components with AppCompat alternatives (e.g., use androidx.appcompat.widget.AppCompatTextView instead of a plain TextView if you’re using Material themes)
    • Avoid layout attributes like android:foregroundTint which weren’t available until API 23
    • Also, check the preview toolbar (if it becomes visible) to ensure you’ve selected an API 22 device for previewing
  • Check your Gradle configuration
    Open your app-level build.gradle file and confirm:

    • compileSdkVersion and targetSdkVersion are set to at least 22
    • You have the AppCompat dependency included (e.g., implementation 'androidx.appcompat:appcompat:1.6.1'—this version works well with API 22)
      After making any changes, sync your Gradle project and try the preview again.
  • Reset the Layout Designer state
    If none of the above works, manually clear the layout editor’s cached state:

    • On Windows: Navigate to C:\Users\<YourUsername>\.AndroidStudio<Version>\system\layout-designer and delete the folder
    • On Mac: Go to ~/Library/Application Support/Google/AndroidStudio<Version>/layout-designer and delete the folder
      Restart Android Studio afterward—this forces the layout editor to rebuild its configuration from scratch.

内容的提问来源于stack exchange,提问作者Arboker

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 07:20:24