0
View imageOverlayView = 
LayoutInflater.from(getApplicationContext()).
inflate(R.layout.layout_image_overlay, null);

new ImageViewer.Builder(getApplicationContext(), imageURLs)
               .setStartPosition(0)
               .hideStatusBar(false)
               .setOverlayView(imageOverlayView)
               .show();

我正在使用此ImageView构建器在全屏视图中加载图像,但在编译时出现上述错误。我使用的活动从AppCompatActivity. 我也尝试了从 Activity 扩展的活动,它不起作用。

非常感谢您在这件事上的时间和帮助。

4

3 回答 3

1

错误:

You need to use a Theme.AppCompat theme (or descendant) with this activity

意味着您需要使用派生自 AppCompat 主题的活动样式。它通常在res/values/styles.xml. 如果你没有创建它是这样的:

<resources>

  <!-- Base application theme. -->
  <style name="AppTheme" parent="Theme.AppCompat">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
  </style>

</resources>

然后,通过将其添加到 AndroidManifest.xml 将其用于您的活动android:theme="@style/AppTheme"(请阅读评论):

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.sample.testcode">

  <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
      <intent-filter>
        <action android:name="android.intent.action.MAIN"/>

        <category android:name="android.intent.category.LAUNCHER"/>
      </intent-filter>
    </activity>

    <!-- Or you can use specific theme for the activity -->
    <activity
        android:name=".anotherActivity"
        android:label="@string/app_name" >
        android:theme="@style/AppTheme" >
    </activity>

  </application>

</manifest>
于 2017-09-21T06:01:12.447 回答
0

.hideStatusBar(假)

正在创造你的问题。

您必须确保 AppTheme 具有已定义的状态和工具栏,并且活动使用主题。

默认情况下,Android Studio 会生成基本主题。

于 2017-09-21T05:37:29.967 回答
0

您在代码部分(即 hideStatusBar)中使用 AppCompat 作为主题,但在清单或 style.xml 中使用了另一个主题。不一致,因为你在两个地方使用不同的主题所以它说你需要使用它。

于 2017-09-21T05:48:19.470 回答