I want to customize the EditText slider style. See my screenshots below.
This is the default slider style:
This is what I want to see:
This may be a dumb question, but after a few hours Googling, I can only find ways to change the cursor color, but couldn't find an approach to change the slider style.
This is the code I am using for changing the cursor color (color_cursor.xml):
<?xml version="1.0" encoding="utf-8" ?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<size android:width="2dp" />
<solid android:color="#008000" />
</shape>
And I applied the "android:textCursorDrawable="#drawable/color_cursor" to EditText.
Thanks.
android:textSelectHandle="#drawable/your_desired_drawable"
put this in your editText view. Set the drawable you prefer. Then change the color inside your drawable xml file.
An answer for myself (hope this will also help others):
After introducing the "Theme.material", the EditText will become the expected style. I will want to check out Material Design.
Related
After the call of EditText.setBackgroundColor(Color.RED) I see only a red rectangle with text inside it, but I want to change only the text background and to keep the standard bottom border which is grey when the field has no focus and blue if it has focus. Can I do it programmatically?
I want to change the text background to red if the input is invalid and to transparent if it is valid.
I think the best way is to work with drawable/shape.xml as background and upon logic code situation call EditText.setBackground(some_other_shape.xml). Here is an example for shape file xml demonstrating how to use:
Border color ("stroke"): In this example some custom color from colors.xml
Fill color ("solid"): In this example Android default transparent color
Even image icon inside
<!--Example for custom shape file xml design-->
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#mipmap/icon_image" />
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#android:color/transparent" />
<stroke android:width="1dp" android:color="#color/orange_primary" />
</shape>
</item>
</layer-list>
So just prepare several shapes for each situation you need. Another approach is to work with layout params etc. but I think this one is faster and gives more control for custom design in easy to understand code.
I want to remove the underlining decoration when I am inputting text into my edit text. And something more, is it possible to get rid of this padding or margin that is between the inputted text and the blue border below it?
Right now the edittext looks like this:
Create a edit_text_background.xml in your drawables folder with following code:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#android:color/white"></solid>
</shape>
Then simply set android:background="#drawable/edit_text_background" field to the same drawable file.
editText.setBackroundDrawable(null);
im trying to make a custom red EditText that takes the background of the fragment layout. I tried a lot of things but i cannot make it transparent in order to use the layout color background. Any ideas?
I tried with this:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="#drawable/red_background"/> -red
<item
android:bottom="10dp"
android:drawable="#drawable/trans_background"
android:top="0dp"/>
<item
android:bottom="#dimen/input_line_width"
android:drawable="#drawable/trans_background"
android:left="#dimen/input_line_width"
android:right="#dimen/input_line_width"
android:top="0dp"/>
</layer-list>
Make sure that #drawable/trans_backgrounds background color code is #00000000
Note: Here color code is not 6digit number. Its 8 digit where 1st 2 digits are for the opacity of the background. It should remove the background visibility.
Finally to accomplish this issue i used this page to draw a 9-patch as #Natix recommended me.
I am developing apps in android. I did design custom edittext for my apps see image.1 for image.1 i used edittext style but I want edittext style like following image.2. does anybody have solution.
image.1
image.1 edittext style
android:background="#drawable/edittext_shape"
following is the edittext.xml
<?xml version="1.0" encoding="utf-8"?>
<item
android:bottom="1dp"
android:left="-4dp"
android:right="-4dp"
android:top="-4dp">
<shape>
<solid android:color="#android:color/transparent" />
<stroke
android:width="2dp"
android:color="#color/marooncolor" />
</shape>
</item>
Following is image.2 whcih is I want
create a 9 patch drawable that will only stretch horizontally and set it as the background of your EditText..
The other way of doing this is use Relative Layout having Edit text and ImageView.
The simplest way is to use android holo colors. Generate styles and 9patch files for your custom EditText, copy and apply to your project. It should work especially if you need the EditText like in Androids Holo Theme.
in my current project I'm building an App with API 10 which should look like an ICS App.
Since my GUI is not very complex I can build this all manually, but I have some problems with button states.
I googled a lot and found nothing that would work for me so I would appreciate any help ;)
I designed an action bar with google ICS stock icons. When for example someone touches the search-loupe-icon, which has an 8dp padding around it, it's background color should change to a defined highlight-color-value.
So now you would suggest probably a selector drawable. But my case is: I have an icon-drawable which has an background-color, which I want to change. I dont want to change the icon, so since I cant change the backgroundcolor from a selector-xml this doesn't work.
(I thought I can setup multiple drawable-xml with my icon static bg colors so that I could refer with one selector to those different colored icons, but since a shape-drawable-xml cannot have a source and an bitmap-drawable-xml cannot have a background color, this is no sollution.)
If I try to change the background color in my onclick-listener (also tried onTouch) with:
ImageButton searchIcon = (ImageButton) findViewById(R.id.upper_actionbar_icon_search);
searchIcon.setBackgroundColor(R.color.android_ics_blue_light);
The Icon gets a dark grey bg color. This is also true for any other color altough nothing lies on top of the ImageButton. I also tried an ImageView.
So could someone explain to my please how the hell I can define a highlighted bg color-image without any hacks (default-gone image that lies above the icon and is set visible onclick).
Thanks so much!!
Okay the solution is simple.
Write yourself a drawable selector which looks like this:
<?xml version="1.0" encoding="utf-8"?>
<item android:state_selected="true">
<shape android:shape="rectangle">
<solid android:color="#color/android_ics_blue_light"/>
</shape>
</item>
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="#color/android_ics_blue_light"/>
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="#color/light_grey"/>
</shape>
</item>
Within your ImageButton code define your icon as src and your new drawable as background, like this:
<ImageButton
<!-- ... -->
android:src="#drawable/icon_search"
android:background="#drawable/actionbar_ontouch"
/>
Works like a charm!