Reputation: 41
View imageOverlayView =
LayoutInflater.from(getApplicationContext()).
inflate(R.layout.layout_image_overlay, null);
new ImageViewer.Builder(getApplicationContext(), imageURLs)
.setStartPosition(0)
.hideStatusBar(false)
.setOverlayView(imageOverlayView)
.show();
I'm using this ImageView
builder to load images in fullscreen view, but I get the above mentioned error while compiling.And the activity which I'm using extends from AppCompatActivity
. Also I tried the activity extending from Activity too, its not working.
Thank you very much for your time and assistance in this matter.
Upvotes: 0
Views: 538
Reputation: 29783
The error:
You need to use a Theme.AppCompat theme (or descendant) with this activity
means that you need to use a style for the activity which is derived from AppCompat theme. It is usually in res/values/styles.xml
. If you don't have create it to something like this:
<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>
Then, use it for your activity by adding it to AndroidManifest.xml with android:theme="@style/AppTheme"
(please read the comment):
<?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>
Upvotes: 1
Reputation: 1196
You used AppCompat as the theme in the code section (that hideStatusBar), but you used another theme in the manifest or style.xml. Not consistent as you use different themes in two places So it says you need to use it.
Upvotes: 0
Reputation: 1493
.hideStatusBar(false)
is creating your issue.
You have to make sure that the AppTheme has a defined Status and Toolbar and the Activity uses the Theme.
By default Android Studio generates the base theme.
Upvotes: 0