This may seem like a dumb question, but I want the magnifying glass on the keyboard, but I don't want the focus to go right to the next element.
I've got an EditText that populates a ListView with possible matches to the user's query. The EditText's XML includes
"android:imeOptions="actionSearch"
which adds the search icon. But it also takes the user to the first element of the ListView which is really annoying.
Is there a way to include the search icon AND not force focus to the ListView?
EDIT:
By request, my EditText xml. Sorry in advance if I mess up the formatting somehow.
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/editSearchWord"
android:imeOptions="actionSearch|normal"
android:inputType="text"
android:drawableLeft="#android:drawable/ic_menu_search"
android:layout_alignParentStart="true"/>
Related
I am new to Android development and need some pointers around the input. I am familiar with the use of Android and I would like to know how to complete general actions around the keyboard.
I know how to set it to things such as phone, email, decimal, and so on.
But how do you change it to move to the next field or fire an action?
Thank you for your insights.
You need to add this attribute in editext xml android:imeOptions="actionDone"
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone"
android:inputType="text"/>
I have a RecyclerView and inside it I want to put CardViews. Now I want these CardViews to overlap themselves like inside a Stackview, but i cannot find a solution to let my view look like this.
The result should look like the reminder app from iOS (see the screenshot) or like a deck of cards. The user should be able to scroll through the cardviews and drag them on the position he wants them to have.
Does anyone have an idea how to solve this problem? Or is there any library that could help me to let my view look like this? I have already tried an custom ItemDecoration but only the visible items of the RecyclerView are shifted and so the RecyclerView has a wrong behavior on scrolling.
You can achieve overlapping of items by using negative bottom margins for your item layout. See the documentations for details.
For example:
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="-10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test"/>
</android.support.v7.widget.CardView>
Using android, I'd like to get a vertical switch widget implementation in place. As far as I can tell, it looks like switches only have a horizontal orientation. I'd like to have something like the following:
After looking through the threads here and searching google, I have yet to find something that can give me this. Everything I search for gives me the horizontal implementation only.
so I can generate your typical horizontal switch
<Switch
android:id="#+id/switch_button"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/label"
android:layout_gravity="center"
android:switchMinWidth="130dp"
android:thumb="#drawable/switch_selector"
android:track="#drawable/track_selector" >
</Switch>
but there doesn't seem to be a good way to set the orientation. I know that the question is a bit high level. Is there some attribute that is immediately available that will allow me to have a vertical switch? Or will I have to create a custom switch and possibly modify the onDraw method so that it is flipped vertically? Any help is appreciated. Thanks.
Try android:rotation="90" like this:
<Switch
android:id="#+id/switch_button"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/label"
android:layout_gravity="center"
android:switchMinWidth="130dp"
android:thumb="#drawable/switch_selector"
android:track="#drawable/track_selector"
android:rotation="90">
</Switch>
There is no quick attribute for vertical orientation.. Sorry :)
First you can look at the code of the switch and see if you can copy and manipulate it.
Second you can just implement your on. Have a layout with a button inside it. use onTouchListener to slide it from side to side. No need to use "onDraw".
Try toggle button witch graphics and use pictures like this You included in Your post. Here is example of such toggle buttons: Toggle button using two image on different state
I'm using RelativeLayout. I understand using Graphical Layout you can't position a button too well. How can I do it in XML? I've tried changing the marginLeft, but nothing moves.
All I want to do is position my buttons!
<Button
android:id="#+id/ListsButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/EditButton"
android:layout_alignBottom="#+id/EditButton"
android:layout_alignParentLeft="true"
android:layout_marginLeft="18dp"
android:text="Li" />
You can use marginLeft, marginRight, marginTop, and marginBottom for small adjustments. If you want to do larger adjustments you can use blank elements in combination with weights, or use a RelativeLayout in combination with alignParentBottom, alignParentTop, alignParentRight, and/or alignParentLeft
If you are beginner in android programming then I would recommend using graphical layout since you won't know every attribute for positioning and styling your views. You can see #Freelancer answer to see how many attributes you have to consider while positioning any view correctly.
Using graphical layout is very easy once you get a little hang of it. You can use Relative Layout which will help you moving any view like button or textView wherever you want. Direct xml coding will require some skills that you will no doubt get in time.
I have a problem here.
I have a large text, that doesn't fit in the screen... So in the layout XML I have put this string:
android:ellipsize="end"
Ok, but now I want to make this TextView clickable and when I click it, I want to change the layout XML code to:
android:ellipsize="marquee"
So the text roll and people will read it.
I've searched lots os questions but none has answered that, just for 'drawable' things.
Thanks!
Use
textView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
on textView Click.