"...must supply a layout_height..." but its in my style resources?

Randy picture Randy · Apr 13, 2011 · Viewed 8.1k times · Source

I had a working app on 2.1 and above until I tried to cleanup my initial layout with a theme of styles. Now the app won't even start with the "You must supply a layout_height attribute" failure message pointing to my first EditText View in the layout.

Why can I not move the 'layout_height=30dp" that was working fine on every EditText into an ... item name="android:layout_height">30dp< ... in a style referred to via my theme?

Virtually all my other style effects I abstracted out like this are working just fine.

[It won't surprise me to learn this must be some styled override to the LinearLayout, not the EditText's. OR that its got to be a styled item for the View, not the Widget. Dunno]

Ideas? Anyone? What is the obvious thing overlooked? THANKS in advance for any suggestions!

AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
...
<application    android:label="xxx"
    android:icon="@drawable/xxx" >

<activity   android:name="DataEntry"
    android:label="xxx"
    android:theme="@style/xxx_theme.A" >
...

xxx_theme.A.xml

<style name="xxx_theme" parent="@android:Theme" >
  <item name="android:windowNoTitle">true</item>
</style>

<style name="xxx_theme.A" >
  <item name="android:textViewStyle">@style/xxx_TextView_widget</item>
  <item name="android:editTextStyle">@style/xxx_EditText_widget</item>
  <item name="android:checkboxStyle">@style/xxx_CheckBox_widget</item>
  <item name="android:radioButtonStyle">@style/xxx_Radio_widget</item>
</style>

<style name="xxx_EditText_widget" parent="@android:style/Widget.EditText" >
  <item name="android:textSize">9dp</item>
  <item name="android:layout_height">30dp</item>
  <item name="android:paddingLeft">8dp</item>
  <item name="android:paddingTop">1dp</item>
  <item name="android:paddingBottom">1dp</item>
  <item name="android:textColorHint">@color/texthint</item>
  <item name="android:singleLine">true</item>
  <item name="android:selectAllOnFocus">true</item>
  <item name="android:inputType">textNoSuggestions</item>
</style>
...

Answer

Jon Willis picture Jon Willis · Apr 13, 2011

You have <item name="android:layout_height">30dp</item> but no android:layout_width in your style.

You need both.