gpt4 book ai didi

android-studio - 图标在操作栏中看起来很平坦

转载 作者:行者123 更新时间:2023-12-03 16:59:50 25 4
gpt4 key购买 nike

我最近将我的 android 项目“升级”到了 SDK 版本 26,现在我的应用栏中的图标看起来像 this (在 Android 6.0 上运行),尽管图标本身看起来像 this .我不知道为什么会发生这种情况,我没有更改 java 或 xml 代码中似乎与此相关的任何内容。
如果有人发布了解决方案,我会很高兴,因为一旦 Android 8 发布,这可能是一个更大的问题。

构建.gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion '26.0.1'

defaultConfig {
applicationId "de.jamesbeans.quadrasolve"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "digit1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:percent:26.0.1'
}

activity_main.xml 的相关部分:
<android.support.v7.widget.Toolbar
android:id="@+id/maintoolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimaryDark"
android:theme="@style/Widget.AppCompat.ActionBar"
android:visibility="visible"
app:popupTheme="@style/Theme.AppCompat.Light"
app:title="QuadraSolve"
app:titleTextColor="@android:color/background_light" />

MainActivity.java 的相关部分:
Toolbar maintoolbar = (Toolbar) findViewById(R.id.maintoolbar);
setSupportActionBar(maintoolbar);

...
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.mainmenu, menu);
return true;
}

主菜单.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_history"
android:icon="@mipmap/ic_history_48px"
android:title="@string/history"
app:showAsAction="ifRoom">
</item>
</menu>

最佳答案

遇到了同样的问题,偶然发现了这个似乎解决了问题的答案:

https://stackoverflow.com/a/45344964/4579919

The matter is that the icon size is bigger then the expected. Obviously the scaling mechanism has changed in SDK 26 and now it leads to this UI bug. Make sure the toolbar icon resources are provided in the following sizes.

关于android-studio - 图标在操作栏中看起来很平坦,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45611508/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com