In some apps I see an EditText widget combined with a Button on the right side (e.g. the search field in the twitter app).
How can I create a widget like that?
Regards,
Marco
I finally found a solution.
Here's how the google guys did it: search_bar.xml
Thanks for your help!
Check out the TableLayout and the RelativeLayout in the Android developer center.
There are a few more official tutorials on layouts here.
If you use the TableLayout, you can put an EditText in the left column of a two column layout, and then put the button on the right. Or, probably a better way, would be to use a RelativeLayout, which gives you a little more flexibility.
Take a look at Applying Styles and Themes and the Draw 9-patch tool. 9-patches are used as the background for widgets like EditText and Button. You can combine a custom widget background with padding and margins to get the effect you want.
Related
I want to customize my textview as per my requirement. I have to add padding or margin dynamically when text is too long and it should look like my screenshot which I have attached here. Can anyone help me how can I implement it and below is my screenshot.
Try using this. It is customizable.
I used it so that I can have different color texts inside my "textview" , and also I used it, cause I did on it a code to resize the text size, so that it fits in the screen height. But if that was possible, I'm pretty sure what you want to do is also possible.
https://github.com/DavidPizarro/AutoLabelUI
I wanted to create a custom text view. A little bit advance just as the text editor found here in StackOverflow, I can insert text and even images. I wanted to name this as WordView and create this as a library so I can reuse this across multiple projects.
Unfortunately I am not so sure if the base class allows this. I need a way to insert/paste images directly in the EditText. I am planning to write a custom View, although it seems laborious, I am not quite certain if this is possible at all and if I am going into the right track.
Have anyone tried similar before?
According to the Android Documentation for a TextView You can have a drawable object inside the TextView in the following ways
DrawableBottom
DrawableEnd
DrawableLeft
DrawableRight
DrawableStart
DrawableTop
There are other methods you can use, check out:
1. Programmatically set left drawable in a TextView
2. How to programmatically set drawableLeft on Android button?
3. http://androidsbs.blogspot.co.za/2013/12/androiddrawableleft-set-drawable-to.html
You could possibly implement this using HTML. I'm not sure about the paste functionality but generally it might work.
good afternoon
How could I get a design like this in my android application?
http://s2.subirimagenes.com/otros/previo/thump_7851660img20120718wa0000.jpg
That is, divided into three areas with different background color to the background activity. And for example in the first zone instead of having these options has a TextView and edit text where you enter something.
How to make something like that image what kind of layout is more recomedable use? Linear, Relative ...
Thanks in advance
You could use a fragment layout and use fragments to get that layout
The best way is to use PreferenceScreen with three PreferenceSections.
When I place things like text boxes they are fixed in one position and I can't move them around easily.
How can I edit the style and maybe put an image at the top of the text boxes and give the app a neat and pretty little layout?
Thanks
Use RelativeLayouts instead of LinearLayouts (i assume that you are using them) which allow free positioning.
To modify the theme/colors, read Applying Styles and Themes.
Create 9-patch graphics and assign them as backgrounds.
I am unsure if this is what you are looking for,but you can arrange the object on the layout from the xml files in res/layouts/ folder.Do not forget to follow the UI guidelines provided by google for android development. Also you can create custom themes for you app if you do not like the default template.
is there any way how to set text on button not from left to right, but from top to down?
Thanks
As far as I know, that's not possible.
However, if you find a solution I would not recommend using it. You're breaking the common way of how Android applications are meant to be designed. If an Android application is meant to be designed that way, Google would have a way to create a Button like you're describing.
May be you can statically specify button layout_width as some 5 dp or lower...and layout_height as wrap_content so that text will wrap next line..
then use setText..
Hope this helps...
If you create an Image, I mean a .png (and store it in drawable). In this png you store your word the way you want to be displayed. Then set that png as the button background then it may work for you.