Issue
I realize this is sort of a weird thing to be doing, but I have a button that needs to look like an EditText but still behave like a button. My layout XML currently looks like this:
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?android:attr/editTextStyle" />
That gives it the appearance of an EditText, but also messes with the behavior a little bit by preventing the onClick event from being fired unless the button has focus (effectively making it require two clicks). Is there any way to keep the style without changing the button's behavior?
I thought about just making a nine-patch background that looks like an EditText, but with so many different Android versions and skins out there I'd rather use the system style if it's possible.
Solution
How about an EditText that behaves like a button?
<EditText android:id="@+id/Edit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:focusableInTouchMode="false"
android:clickable="true"/>
You can define an OnClickListener for it too. And it won't get focus.
Answered By - Zsombor Erdődy-Nagy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.