작업 표시 줄에서 오버플로 아이콘 변경
작업 표시 줄에서 오버플로 아이콘을 변경할 수 있습니까? 모든 ActionBar 항목에 파란색 아이콘이 있으며 오버플로 아이콘이 나타나면이를 변경하고 싶습니다.
스타일을 사용할 수 있지만 기본 테마 선언에 스타일을 추가해야합니다.
<resources>
<!-- Base application theme. -->
<style name="Your.Theme" parent="@android:style/Theme.Holo">
<!-- Pointer to Overflow style ***MUST*** go here or it will not work -->
<item name="android:actionOverflowButtonStyle">@style/OverFlow</item>
</style>
<!-- Styles -->
<style name="OverFlow" parent="@android:style/Widget.Holo.ActionButton.Overflow">
<item name="android:src">@drawable/ic_action_overflow</item>
</style>
</resources>
동적으로 변경할 수도 있습니다. 여기에서 자세히 설명하겠습니다.
프로그래밍 방식으로 Android 오버플로 메뉴 아이콘 변경
작동하지 않는 사람들을 위해 "android :"네임 스페이스없이 이것을 시도하십시오.
<item name="actionOverflowButtonStyle">@style/OverFlow</item>
styles.xml에서 작업 표시 줄의 사용자 정의 오버플로 아이콘을 변경하십시오.
<resources> <!-- Base application theme. --> <style name=“MyTheme" parent="@android:style/Theme.Holo"> <!-- Pointer to Overflow style DONT forget! --> <item name="android:actionOverflowButtonStyle">@style/MyOverFlow</item> </style> <!-- Styles --> <style name="MyOverFlow" parent="@android:style/Widget.Holo.ActionButton.Overflow"> <item name="android:src">@drawable/ic_your_action_overflow</item> </style> </resources>
AndroidManifest.xml의 애플리케이션 태그에 커스텀 테마 "MyTheme"넣기
<application android:name="com.example.android.MainApp" android:theme="@style/AppTheme"> </application>
재미있게 보내세요. @. @
에서 무엇을하려고하더라도 styles.xml
솔루션 중 어느 것도 나를 위해 일하지 않았습니다. 결국, AppCompat 23+가 있다면 이것이 실제로 작동하는 가장 쉬운 방법입니다.
toolbar.setOverflowIcon(drawable);
@adneal의 답변 은 정확합니다 (따라서 커뮤니티 위키 설명으로 확대됩니다).
의견 중 하나는이 작업을 수행하는 방법에 대한 오해가있을 수 있다고 제안 했으므로 오버플로 아이콘 이미지를 재정의하는 방법에 대한 또 다른 예입니다.
아래 코드는 ADT 샘플 New Android Project의 템플릿 스타일을 기반으로합니다. 코드는 폴더 의 styles.xml
파일에서 가져 옵니다 res/values
.
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:actionOverflowButtonStyle">@style/OverflowMenuButton</item>
</style>
<style name="OverflowMenuButton" parent="@android:style/Widget.Holo.ActionButton.Overflow">
<item name="android:src">@drawable/ic_menu_moreoverflow</item>
</style>
이 코드의 기능은 기본 오버플로 아이콘을 이름이 지정된 드로어 블로 바꾸는 것입니다 ic_menu_moreoverflow
. 빠른 테스트 방법을 원한다면 앱의 런처 아이콘 파일 이름을 사용하면 작동 방식을 분명히 알 수 있습니다.
ActionBar
스타일 을 이해하려고 할 때 유용한 리소스 는 다음과 같습니다.
There you can define specific colours to use for your Overflow icon, and the ZIP file will include the correct styles.xml
file for you.
After long search what i got the guidance to be followed like:
- Check the theme in the manifesto file.
- Then go to res->values->themes.
- Find the theme name in this file .
Add the item within the theme in the theme.xml:
<item name="android:actionBarWidgetTheme">@style/widgetStyle</item> <item name="android:actionOverflowButtonStyle">@style/MyActionButtonOverflow</item>
Add the icon in the style in the same file I mean theme.xml:
<style name="MyActionButtonOverflow" parent="android:style/Widget.Holo.ActionButton.Overflow"> <item name="android:src">@drawable/icon_menu</item> </style>
Check out the custom icon which you want to change
It worked for me
For Overflow icon color change, you can just add
toolbar.setOverflowicon(getDrawable(R.id.whiteIcon));
or
toolbar.setOverflowicon(getDrawable(R.id.redIcon));
It will change the icon, choose whatever color you want and set as an Overflowicon.
참고URL : https://stackoverflow.com/questions/9733312/changing-overflow-icon-in-the-action-bar
'Programing' 카테고리의 다른 글
파이썬에서 현재 모듈의 속성에 대한 참조를 얻는 방법 (0) | 2020.07.30 |
---|---|
React useEffect로 로딩 함수를 한 번만 호출하는 방법 (0) | 2020.07.30 |
Bash에서 시간 초과로 프로세스를 실행하는 방법은 무엇입니까? (0) | 2020.07.30 |
NPM 스크립트를 순차적으로 실행 (0) | 2020.07.30 |
이진 검색 트리에서 최적의 방법으로 k 번째로 작은 요소 찾기 (0) | 2020.07.30 |