4

アプリのロゴの左側にあるパディングを削除する方法を教えてもらえますか?

これが私が話していることですhttp://s9.postimage.org/ksxjpx1e7/Untitled.png

に追加することで、ABS デモでもこれを簡単に再現できます。AndroidManifest.xml

android:logo="@drawable/icon"

私も直接編集しようとabs__action_bar_home.xmlしましたが、どういうわけかそのパディングはまだそこにあります。

<view xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    class="com.actionbarsherlock.internal.widget.ActionBarView$HomeView"
    android:background="#00ff00" >


    <ImageView
        android:id="@id/abs__home"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="left"
    android:padding="0dip"
    android:layout_marginLeft="0dip"
        android:layout_marginBottom="@dimen/abs__action_bar_icon_vertical_padding"
        android:layout_marginRight="8dip"
        android:layout_marginTop="@dimen/abs__action_bar_icon_vertical_padding"
        android:adjustViewBounds="true"
        android:contentDescription="@null"
        android:scaleType="fitCenter" />

        <ImageView
        android:id="@id/abs__up"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical|left"
        android:layout_marginRight="-8dip"
        android:contentDescription="@null"
        android:src="?attr/homeAsUpIndicator"
        android:visibility="gone"
        tools:ignore="ContentDescription" />


</view>
4

1 に答える 1

8

コメントの1つが指摘したように、パディングはアップアイコン用に予約されています。上向きアイコンが表示されていなくても、パディングは存在します (上向きアイコンを非表示/表示するときにロゴが移動しないようにするため)。アクションバー (およびActionBarSherlock) を使用して、ギャップを削除する方法は基本的に 2 つあります。

1.上向きアイコンを削除 上向きアイコン
のサイズは左パディングに影響します。矢印よりも大きな画像をそこに配置すると、ギャップが大きくなります。外すと隙間がなくなります。アップ アイコンを削除すると、希望どおりの外観にならない場合があることに注意してください。上向きアイコンとロゴは部分的に重なっている (上向きアイコンには負の右余白がある) ため、上向きアイコンを削除すると (実際には画像が何も設定されず、可視性には影響しません)、ロゴの左端の後ろに部分的に隠れる場合があります。画面。に設定されて
いるアップ アイコンを削除します。android:homeAsUpIndicator@null

<style name="MyTheme" parent="@style/Theme.Sherlock">
    <item name="homeAsUpIndicator">@null</item>
    <item name="android:homeAsUpIndicator">@null</item>
</style>

2.ホーム レイアウトを非表示にし、代わりにカスタム ビューを使用します
。アイコンとタイトルをカスタム ビューに配置する必要があります。ホーム レイアウトを非表示にしてカスタムを表示するandroid:displayOptionsには、アクション バー スタイルで設定する必要があります。そして、コードで適切なカスタム ビューを設定します (スタイルでも設定できますが、その方法ではバグがあります)。

<style name="MyTheme" parent="@style/Theme.Sherlock">
    <item name="actionBarStyle">@style/MyActionBarStyle</item>
    <item name="android:actionBarStyle">@style/MyActionBarStyle</item>
</style>

<style name="MyActionBarStyle" parent="@style/Widget.Sherlock.ActionBar">
    <item name="displayOptions">showCustom</item>
    <item name="android:displayOptions">showCustom</item>
</style>
于 2013-01-25T10:24:32.663 に答える