Android studio downloading button designs - android

I am trying to make a well designed app in Android-Studio, but I just can't get the buttons right. Where can I find good examples for button style?

1st you can get buttons from the default system resources and also download or create your own button img file of at least 30x80

I'm not sure if this would help but you can do it yourself:
In your "drawable folder" you can create a new "drawable resource file" and place this code there:
<shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android">
<size android:height="50dp" android:width="50dp"></size>
<solid android:color="#color/colorPrimaryDark"></solid>
<corners android:radius="23dp"></corners>
In the xml file where you'll want to use it, add this piece of code to your "button tag" :
android:background="#drawable/round_button"

Related

Android - How to give your layout a 3D style?

I was surfing the web to find a new style for the android layout and I find a pretty interesting one. Here is the Image.
I know more than basics about layout, but what I wanna is how can I give a 3d style look like in the above image? Especially that #7881 Code Box.
Here is Something that I have tried.
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:bottom="-25dp"
android:top="-25dp"
android:left="25dp"
android:right="25dp">
<rotate android:fromDegrees="20">
<shape android:shape="rectangle">
<size
android:width="50dp"
android:height="100dp"/>
<solid android:color="#E30B3E"/>
</shape>
</rotate>
</item>
</layer-list>
The output is this
Overall it gives the textview a 3d look but I want something like that in the image.
Any Suggestions?
Its pretty much simple just use android:rotationX property on the CardView
like this
<com.google.android.material.card.MaterialCardView
...
android:rotationX="20"
...
That's easy as long as the box should not be animated in its shape.
Go to https://www.figma.com/ and start a new project (it's free)
Export any shape you create there as svg
Import this svg into Android Studio using the Resource Manager
add your new drawable as background of the box.
Additional input, so your 50 points aren't wasted ;) :
You find several Android Presets for figma. Like UI Elements or buttons. For example here. For more just google for "Figma Android UI kit"
You can edit the generated SVG to your likes. Since it is only a text file, you can customize its colors (also using backgroundTint in xml), etc.

How to glow effect behind the edit text like in the image?

I am trying to get a glow effect like the background for edittext
I tried doing it but the background is not as much effective as the image
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#68F30606"/>
<corners android:radius="10dp" />
</shape>
</item>
<item
android:left="1.7dp"
android:right="1.7dp"
android:top="1.7dp"
android:bottom="1.7dp">
<shape android:shape="rectangle">
<solid android:color="#android:color/white"/>
<corners android:radius="10dp" />
</shape>
</item>
</layer-list>
Can someone help me to solve this mystery?
Then you will need to use the old-technique(kind of) of 9-Patch Drawing. I used to do it too. Examples are scarce because they are big, but there is documentation.
Documentation: https://developer.android.com/studio/write/draw9patch.
Also, if this helps you can check this too: Outer glow in edittext
To use the 9-Patch images in Xml to this (remember this is after you have created the 9-Patch Images):
Reference the drawable with the name but don't include .9.png (auto-complete in eclipse will take care of this)
Make sure you only have 1 image under the main /drawable folder (not a version for each dpi folder)
The image must be specified using :background, not :src (this got me stuck for a while)
android:background="#drawable/splash_logo"
Make sure the image and layout that contains it are using:
android:layout_width="fill_parent"
android:layout_height="fill_parent"
Credit To: Creating & Using 9-patch images in Android
Also, check this website out, it contains a lot of useful examples that the documentation doesn't provide:
https://tekeye.uk/android/examples/ui/android-9-patch-image-files

Android: Where to find Seekbar drawable "scrubber_control_normal_holo"

My primary problem is I want to increase the size of the thumb of the Seekbar, so I found this post: Changing size of seekbar thumb
From there it said i can create thumb_size.xml and add the below code inside:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape>
<size
android:height="40dp"
android:width="40dp" />
<solid android:color="#android:color/transparent" />
</shape>
</item>
<item android:drawable="#drawable/scrubber_control_normal_holo"/>
However then the Android Studio give me error message saying that it cannot find the
scrubber_control_normal_holo
Then I find this post: Android: Where to find the RadioButton Drawable?
However in my SDK folder /platforms/android-17/data/res/drawable folder, I still cannot find this file, I can only find something like:
seek_thumb.xml
but when I try to use it, it still give me error.
At last I can find the resource images in the following folders (for different device size):
SDK folder\platforms\android-17\data\res\drawable-hdpi
SDK folder\platforms\android-17\data\res\drawable-mdpi
SDK folder\platforms\android-17\data\res\drawable-xhdpi
SDK folder\platforms\android-17\data\res\drawable-xxhdpi
SDK folder\platforms\android-17\data\res\drawable-xxxhdpi

Setting background in XML format in Visual Studio 2010

I asked this question in chat rooms tagged with Android but it turns out they didn't encounter this before, and I cannot find specific question either on Google so I think this is a valid point to post this as a question here.
The problem is, if I refer to an XML file format as android:background="#drawable/bg", I got compilation error saying:
No resource found that matches the given name (at 'background' with value '#drawable/bg').
But if I put some file like for e.g ".png" or ".jpg", it compiles well. Sounds like it does not recognize the file as a valid drawable? Either if I put that file in other location, its just don't compile.
This is the bg.xml contains:
<?xml version="1.0" encoding="utf-8" ?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="2dp" />
<stroke
android:width="1dp"
android:color="#fff" />
</shape>
What am I doing wrong?
Edit:
I've create the "res" and "drawable" folders by myself because it's not default in this kind of environment.
Set the Build Action property of item bg.xml to DrawableResource.
I am also facing this problem in VS 2013. Then i do this..
In the solution explorer click on drawable folder and check if your image exists here or not. If not then right click on drawable folder and click add-> existing item and then add your Image here.

How to preview xml drawable?

I'm working on pretty complex xml drawable and i was wondering if there is any tool/plugins which allow me to preview my drawable ?
I'm looking for something similar to the "Graphical layout" tab available for layout.
For example if i have something like this :
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:left="0dp" android:right="0dp">
<shape android:shape="rectangle">
<gradient android:angle="-90" android:startColor="#2B2B2B"
android:endColor="#000000" />
</shape>
</item>
<item android:top="1sp" android:bottom="26sp" >
<shape android:shape="rectangle">
<solid android:color="#10ffffff"/>
</shape>
</item>
</layer-list>
How can i preview the shape and gradient ?
And i'm probably dreaming , but is there any graphical tools to build a drawable ?
In Android Studio do this: View -> Tool Windows -> Preview
Android Studio has support for this starting with version 0.3.2: http://tools.android.com/recent/androidstudio032released
Click on PREVIEW on the right side of the window.
In Eclipse
Create new layout with root LinearLayout.
Open Outline view.
In properties table find View.Background.
Press button ...
Now you can chose Color and Drawable resources and there is small preview.
Android Studio offers a nice plugin named
"Vector Drawable Thumbnails"
This adds a nice overview over all vector drawables in your project.
Just have a look at the side bar and open the view. You will get a thumbnail table of them.
Another possibility:
Just create a new layout "test", goto graphical layout, create a button inside (or any view), and assign the drawable to the button's background. The drawable is rendered (its normal state).
Android Studio 2X
View -> Tool Windows -> Preview
Or click on Preview on the right side
One way to preview the resources is by using the Resource Manager in Android Studio. It's visible as a separate tab:
If you would like to preview selector you can find tabs with states on Preview Panel
The Preview options mentioned in previous answers aren't there in Android Studio 4.0. Look for this segmented control in the top-right of the editor tab instead.

Categories

Resources