I’ve got a Button next to EditText control wrapped in LinearLayout. Everything seems to be fine except that the Button is significantly higher than the EditText and I’d like it to be the same height. The heights of @drawable/main_edittext and @drawable/main_edittext_button are the same, but even without background set, heights are different. In the application manifest file, application theme is set only to windowNoTitle=true.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:background="@drawable/main_background"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<EditText
android:id="@+id/edit_message"
style="@style/MainEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/edit_message"
android:singleLine="true" />
<Button
android:id="@+id/edit_message_button"
style="@style/MainSearchButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="sendMessage"
android:text="@string/button_send" />
</LinearLayout>
<style name="MainEditText">
<item name="android:background">@drawable/main_edittext</item>
<item name="android:textSize">16sp</item>
<item name="android:textStyle">normal</item>
<item name="android:textColor">#262626</item>
</style>
<style name="MainSearchButton">
<item name="android:background">@drawable/main_edittext_button</item>
<item name="android:textSize">16sp</item>
<item name="android:textStyle">normal</item>
<item name="android:textColor">#ff5500</item>
</style>
+main_edittext.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:drawable="@drawable/edit_text">
</item>
<item
android:state_enabled="true"
android:state_focused="true"
android:drawable="@drawable/edit_text">
</item>
<item android:state_enabled="true"
android:drawable="@drawable/edit_text">
</item>
</selector>
-main_edittext.xml
+main_edittext_button.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:drawable="@drawable/edit_text_button">
</item>
<item
android:state_focused="true"
android:drawable="@drawable/edit_text_button">
</item>
<item android:drawable="@drawable/edit_text_button" />
</selector>
-main_edittext_button.xml
Try to remove the padding and margins:
android:layout_margin="0dp"andandroid:padding="0dp"Also, per your comment, modify the
minHeightto 0 as well:android:minHeight="0dp"