As the question states, I'm running into some weird behavior where my left drawables are not given any left padding on an HTC One running Android 4.4.
The layout where I'm seeing this is
<LinearLayout>
<include layout="@layout/search_bar" />
<!-- Some Fragment layout information -->
</LinearLayout>
Inside search_bar I have a Layout which looks like.
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp">
<EditText
android:layout_width="match_parent"
android:layout_height="56dp"
style="@style/SearchBox.SingleSearchBar" />
</FrameLayout>
The SearchBox.SingleSearchBar style looks like (after some massaging of the style hierarchy).
<style name ="SearchBox.SingleSearchBar" parent="@android:style/Widget.TextView">
<item name="android:focusable">false</item>
<item name="android:gravity">center_vertical</item>
<item name="android:singleLine">true</item>
<item name="android:lines">1</item>
<item name="android:imeOptions">actionSearch|flagNoExtractUi</item>
<item name="android:layout_centerHorizontal">true</item>
<item name="android:selectAllOnFocus">true</item>
<item name="android:drawableLeft">@drawable/gray_magnifying_glass</item>
<item name="android:scrollHorizontally">true</item>
<item name="android:paddingLeft">@dimen/search_drawable_padding</item>
<item name="android:paddingRight">@dimen/search_drawable_padding</item>
<item name="android:paddingTop">@dimen/search_drawable_padding</item>
<item name="android:paddingBottom">@dimen/search_drawable_padding</item>
<item name="android:drawablePadding">@dimen/search_drawable_padding</item>
<item name="android:maxLines">1</item>
<item name="android:background">@drawable/search_bar_selector</item>
<item name="android:textAppearance">@style/TextAppearanceSearchBox</item>
<item name="android:textCursorDrawable">@drawable/search_box_cursor</item>
</style>
On every device that I've seen except for the HTC One, this runs fine: the left drawable is padded in search_drawable_padding dips from the left, and there is appropriate padding between the drawable and the text. However, for some reason, on the HTC One, there is no padding between the left edge of the text box and the drawable.
I logged the value for both getPaddingLeft() and getPaddingTop and found that on the HTC One they are 0px, while on a Samsung GS4 they are 48 pixels, which makes sense given that search_drawable_padding is 16dips.
Is there any way around this? Am I missing something really stupid that is forcing me to call setPadding in code in order to make this work?