Is there a best practices size (in dip?) that buttons should be in order to be easily touchable?
See https://support.google.com/accessibility/android/answer/7101858?hl=en which says that a touch target should — at minimum — be 48x48dp
Outdated (see comments below): Android Design Guidelines specifically call out 48dp as the recommended minimum size for any touchable object. See "48dp Rhythm": http://developer.android.com/design/style/metrics-grids.html
You may find this helpful: http://www.lukew.com/ff/entry.asp?1085. About 8mm (50 dips) should be OK.
Just take a look at the Android Design Guidelines for Buttons:
Source: https://material.io/guidelines/components/buttons.html#buttons-style
<shape android:shape="rectangle">
<corners android:radius="1000dp" />
<solid android:color="#color/light_blue" />
<stroke android:width="2dip" android:color="#215368" />
<padding android:bottom="4dp" android:left="4dp" android:right="4dp"
android:top="4dp" />
</shape>
this for round button, make sure the width and height is same.
Related
I have a custom SeekBar that uses LayerList as progress drawable. On Android device with API <22 it seems to work fine, however on API 22 the progress drawable is not displayed.
Here's my LayerList code:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#android:id/background">
<shape android:shape="rectangle">
<corners android:radius="20dp"/>
<gradient android:startColor="#0e0e0f" android:endColor="#373938" android:angle="270"/>
<stroke android:width="10dp"
android:color="#2d3035" />
<size android:height="3dp" android:width="500dp"/>
</shape>
</item>
<item android:id="#android:id/progress">
<clip>
<shape android:shape="rectangle">
<corners android:radius="20dp"/>
<solid android:color="#45ab12" />
<stroke android:width="10dp"
android:color="#2d3035" />
<size android:height="3dp" android:width="500dp"/>
</shape>
</clip>
</item>
And here's my Seekbar:
<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:splitTrack="false"
android:thumbOffset="5dp"
android:id="#+id/firstAudioPositionSeekBar"
android:thumb="#drawable/seekbar_thumb"
android:progressDrawable="#drawable/seekbar_progress_bg"/>
Here are screen shots of the SeekBar on API 22 and lower:
I'm having similiar issue on API 22 and found your question. Did you find a good solution for that? What I've noticed till now, with many experiments:
1. Without solid on API 22 the progressbar is drawn
2. Stroke values are drawn different on API 22 devices than on all upper APIs, what is very strange, cause it doesn't even take care of screen size.. what the hell?
3. Even when u change stroke to proper one on API 22 - it still is MUCH MUCH different on small resolutions (480/800) and all other screen sizes..
I found a solution thought, but I don't think it is the best one. I created 3 separate drawable files (layer list): one for API 22 with small resolution, one for API 22 with all other resolutions, and one for all API's above 22. I removed stroke from those with API 22 and put inside item values:
<item android:id="#android:id/background" android:top="15dp" android:bottom="15dp">
I have tested it for 10 different phones with different resolutions - it works perfectly, even for big tablets. Still, I think there must be a better solution for this.
Best regards,
Max
Does anyone know how to do textview list like in attached image ?
Children in multiple rows depending on their size.
This might help you to arrrange your tags.
FlowLayout
Check below links, it might help you.
Use multiple autocompleted textview :Bubble-Text-Library(you can change view from xml file also) Link
android-chips(suggested by # Suhas Bachewar) Link
chipview(multi custom color) Link
and many more are there
Set it as your textView background
Save it in drawable folder
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:endColor="#color/something"
android:centerColor="#color/something_else"
android:startColor="#color/something_else_still"
android:angle="270" />
<corners
android:radius="3dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
Not exact, but you can edit it, to match your requirement
I'm making an app with custom buttons, but I want to know is it better to use the nine-patch tool or define styles and colors in xml. My buttons change in height and width but they do not have images, just words, something like this:
Please check this link also. What should i use for better performance, nine-patch or drawable xml resource?. Both approaches have is own merits. Select one option as per your situation
no you don't need to use nine-patch just give the width,height,and text sizes in values folder.
Seems like a fairly simple shape, you might as well use a shape to create the background.
first create a button_shape.xml file in drawable resource directory:
<?xml version="1.0" encoding="UTF-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="1dp"
android:color="#505050"/>
<corners
android:radius="7dp" />
<padding
android:left="1dp"
android:right="1dp"
android:top="1dp"
android:bottom="1dp"/>
<solid android:color="#505050"/>
</shape>
Now, assign it to the backround of you Button.
android:background="#drawable/button_shape"
You will need to change some of the color values to fit your needs
I want to make my EditText Opacity to 1 which will ensure that it looks like disabled. But since my API level is set to 8, i am not able to apply this method.
Is there anyway we can disable the EditText and Grey it out, so that i looks disabled.
Yes, you can use setEnabled(false) and then apply this kind of style on the button (in the layout xml file):
<item android:state_enabled="false" >
<shape>
<gradient
android:endColor="#007900"
android:startColor="#009A77"
android:angle="270" />
<stroke
android:width="1dp"
android:color="#F1FAFE" />
<corners
android:radius="5dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
Customise the values with colors and effects you want.
Edit:
You will find everything you want to learn how to apply a style on any UI element here: http://www.devahead.com/blog/2011/08/creating-a-custom-android-button-with-a-resizable-skin/
The example is about buttons but it is the exact same method for any other view.
Try:
editText.setEnabled(false);
What I'm trying to do will work better with an example image. As you can see below I have a grey background, ontop of that sits a container with some padding containing an image. The container also has a slight dropshadow to it.
What I want to know, is if there's so non-painstaking way of doing this in my layout.xml? In a normal HTML document this would've been easy. But since this is for a mobile app and for a number of screen resolutions and so on, it's proving a bit difficult.
Any advice?
Edit: I eventually settled using a 9patch image. Everyting went really smooth in the creation of it but when I actually use it in my app I see these dark stripes on the right and bottom of the image. The dropshadow seems to work, it's a very light dropshadow.. but those darn stripes??
You can provide a border to a view by writing an xml file (say editBorder.xml) in drawable folder:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<stroke
android:width="5dp"
android:color="#EBDDE2" />
<padding
android:bottom="2dp"
android:left="2dp"
android:right="2dp"
android:top="4dp" />
<gradient
android:centerColor="#color/white"
android:endColor="#color/white"
android:startColor="#color/white" />
<corners android:radius="8dp" />
</shape>
and to provide this border, use statement in ImageView as android:background="#drawable/editBorder"
This should solve your problem. :)
This can be done with proper padding and 9 patch image. See this link, may be it can help you.
ImageView having two property android:background and android:src
http://developer.android.com/reference/android/widget/ImageView.html
Create a blank white frame with drop shadow(Photoshop recommended).
So just do this
<ImageView android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/image"
android:background="#drawable/whiteFrame"
android:padding="10dp" >
</ImageView>
I found this imageView . It's may good for you