2

XMLテーマを使用して、アクションバーアイコンまたはロゴスペースの上下のパディングまたはマージンを変更する方法は?

<style name="Theme.Whycheck" parent="@style/Theme.AppCompat.Light.DarkActionBar">
    <item name="actionBarItemBackground">@drawable/selectable_background_whycheck</item>
    <item name="actionBarStyle">@style/ActionBar.Solid.Whycheck</item>
    <item name="actionModeBackground">@drawable/cab_background_top_whycheck</item>
    <item name="actionModeSplitBackground">@drawable/cab_background_bottom_whycheck</item>

            <!-- Light.DarkActionBar specific -->
    <item name="actionBarWidgetTheme">@style/Theme.Whycheck.Widget</item>

</style>

<style name="ActionBar.Solid.Whycheck" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
    <item name="background">@drawable/ab_solid_whycheck</item>
    <item name="backgroundStacked">@drawable/ab_stacked_solid_whycheck</item>
    <item name="backgroundSplit">@drawable/ab_bottom_solid_whycheck</item>
</style>

<style name="ActionBar.Transparent.Whycheck" parent="@style/Widget.AppCompat.ActionBar">
    <item name="background">@drawable/ab_transparent_whycheck</item>
</style>

<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Whycheck.Widget" parent="@style/Theme.AppCompat">
</style>

私のスタイルを提供しました。

4

2 に答える 2

4

ここでの解決策は私にはうまくいきませんでした。これが私が解決した方法です:

<application>これをマニフェストのタグに追加します

android:logo="@drawable/logo"

注: あなたlogoiconは同じものではありません!

次に、作成しますdrawable/logo.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:drawable="@drawable/actual_logo_or_icon_image"
        android:left="30dp"/> <!-- add other margins here -->
</layer-list>
于 2013-09-12T12:03:15.313 に答える
0

Action Bar Sherlock を使用している場合は、この回答を確認してください: Action Bar sherlock のパディング メニュー項目

また、ホームアイコンに次のようなものを書くこともできます:

ImageView im = ( ImageView ) findViewById ( android.R.id.home );
im.setPadding ( left, top, right, bottom );
于 2013-09-12T12:13:47.683 に答える