Android studio 为什么不';当我使用Android Studio创建应用程序时,标题栏中的应用程序图标是否会显示?
在我用eclipse创建Android应用程序之前,它可以在标题栏的左侧显示应用程序图标,请参见图片aa.png 现在我用Android Studio创建Android应用程序,我已经将代码Android studio 为什么不';当我使用Android Studio创建应用程序时,标题栏中的应用程序图标是否会显示?,android-studio,Android Studio,在我用eclipse创建Android应用程序之前,它可以在标题栏的左侧显示应用程序图标,请参见图片aa.png 现在我用Android Studio创建Android应用程序,我已经将代码Android:icon=“@mipmap/ic_launcher”添加到manifest.xml文件中,但是应用程序图标不显示,请查看图片bb.png,为什么 顺便说一句,如果我将compile'com.android.support:appcompat-v7:22.1.1'替换为compile'com.a
Android:icon=“@mipmap/ic_launcher”
添加到manifest.xml文件中,但是应用程序图标不显示,请查看图片bb.png,为什么
顺便说一句,如果我将compile'com.android.support:appcompat-v7:22.1.1'
替换为compile'com.android.support:appcompat-v7:18.0.0'
,图标会显示,为什么?com.android.support:appcompat-v7:22.1.1是否存在一些bug
aa.png
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.cuiwei.myapplication" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".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>
<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=".MainActivity">
<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.cuiwei.myapplication"
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
}
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
bb.png
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.cuiwei.myapplication" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".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>
<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=".MainActivity">
<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.cuiwei.myapplication"
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
}
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
应用插件:“com.android.application”
安卓{
编译DK22版
buildToolsVersion“22.0.1”
默认配置{
applicationId“com.example.cuiwei.myapplication”
明斯克版本9
targetSdkVersion 22
版本代码1
版本名称“1.0”
}
建筑类型{
释放{
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard rules.pro'
}
}
}
依赖关系{
编译文件树(目录:“libs”,包括:['*.jar'])
编译'com.android.support:appcompat-v7:22.1.1'
}
如果它不起作用,您应该使用Android 5.0样式(即AppCompat)在活动中调用getSupportActionBar().setIcon(Drawable/int)
或getSupportActionBar().setLogo(Drawable/int)
,应用程序图标不会显示在操作栏中
如果你使用安卓全息主题,你应该能够看到应用程序图标。为此,将android:theme更改为“android:theme.Holo”或“android:theme.Holo.Light”
希望这有帮助。谢谢!但是getSupportActionBar().setIcon(@mipmap/ic_launcher);哦,来吧setIcon(R.mipmap.ic_launcher)
。顺便说一句,在我将android:icon=“@mipmap/ic_launcher”添加到后,图标不会显示,因此您需要以编程方式执行。谢谢!我已经添加了代码setIcon(R.mipmap.ic_launcher),但是图标不显示yetThank!但是“android:Theme.Holo.Light”需要的最小API是11,现在我的最小API是9。我已经导入了“导入android.support.v7.app.AppCompatActivity”,还有什么想法吗?谢谢