如何在android中为ImageView创建全屏主题?

时间:2014-05-28 06:28:55

标签: java android xml eclipse android-studio

我想在我的应用程序中添加ImageView,然后将其设置为全屏。

我曾尝试在Android Studio中使用代码。(我也在Eclipse IDE中尝试过)

我的最低要求

  

SDK :API 8:Android 2.2 froyo,
     目标 SDK:API 19:Android 4.4 KitKat,
     编译:API 19:Android 4.4 KitKat,
      Langauge等级:界面中的6.0-ovrrride,
     主题:Holo Light With Dark Action Bar。

然后在activity_main.xml中的代码如下:

<RelativeLayout 
    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:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context="com.example.crystal.app.MainActivity">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageView"
        android:layout_alignParentLeft="true"
        android:src="@drawable/ddd" />

</RelativeLayout>

我将主题设置为Theme.Black.NoTitleBar.Fullscreen

我更改了AndroidManifest.xml代码如下:

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >

        <activity
            android:name="com.example.crystal.app.MainActivity"
            android:label="@string/app_name" >

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        </activity>

    </application>

</manifest>

然后我在AVD中运行应用程序,但是当我打开应用程序时,它会显示错误,如:

  

不幸的是,(app name)已停止(和OK按钮)

所以,我的代码出了什么问题。

并告诉我有多少方法可以做到这一点。 提前谢谢。

1 个答案:

答案 0 :(得分:0)

正如我上面提到的,我的最低要求sdk是Android 2.2 froyo,不支持

android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" 

只有14级以上的api级别支持(Icecream Sandwitch) 所以我的最低要求sdk应该是Android 4.0或Android API级别应该大于或等于14。