I'm using an EditText
into the ActionBar
as custom view.
LayoutInflater adbInflater = LayoutInflater.from(getActivity());
View etSearchView = adbInflater.inflate(R.layout.edit_text_search, null);
etSearch = (EditText) etSearchView.findViewById(R.id.search_edit_text);
//other etSearch properties are set
MainActivity.ab.setCustomView(etSearch);
edit_text_search.xml:
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/search_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text|textAutoCorrect"
android:hint="@string/keywords"
android:imeOptions="actionSearch"
android:hapticFeedbackEnabled="true"
android:singleLine="true"
android:textCursorDrawable="@drawable/cursor"
android:textColor="@android:color/white">
</EditText>
I have this behaviour... (undesired)
On the other hand, when the EditText
's width and height are declared in code with
LayoutParams layoutParams = new LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
etSearch.setLayoutParams(layoutParams);
and removing android:layout_width="match_parent"
and android:layout_height="wrap_content"
from the xml file, I have this (desired) look...
How is this possible, with the same width and height?
Is this because, in code, they imply the addition of a wrapping layout?