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.
Related
what is the essence of the question:
Why is the color that I write in solid in the shape not taken into account
Why do I have a white background on the back of the button now (attached a photo)? I don't understand where I can fix it
I found a video on YouTube and there was the following solution: Create an xml file in drawable and there I specified the following:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="oval">
<solid android:color="#color/teal_700"></solid>
</shape>
</item>
</selector>
The problem is that when the videos came out, there were no themes and everything worked out perfectly right away, and I tried to figure out why I didn't apply color to the button if I set it in the shape, but I never figured it out and it doesn't take into account my color that I set in solid :) I decided to change the primaryColor in the theme to the color I needed and then it applied.
And can you also throw, please, useful modern resources to the latest versions of android studio? I'm just learning, so I haven't found much yet and it would be interesting to see some examples for new updates, because all the videos are from earlier versions and some of them don't converge, as, for example, now in the question
If there are not enough details to solve the problem, then write to me
To make A Button Round Use MaterialButton
<com.google.android.material.button.MaterialButton
android:layout_width="100dp"
android:layout_height="50dp"
android:text="1"
app:cornerRadius="18dp" />
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.
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"
I have a Button that looks according to the Theme.Holo.Light. I used to round its corners by setting its background to the following:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle" >
<corners
android:bottomLeftRadius="15dp"
android:bottomRightRadius="15dp"
android:topLeftRadius="15dp"
android:topRightRadius="15dp" />
</shape>
Now the Button becomes transparent. I tried to create a selector, add a solid attribute and use 2 of such drawables for normal and pressed states, but I could not copy the default Button behavior of the Holo.Light theme. So I'm looking for 2 possible solutions: either somehow round the Button's corners without affecting its default Style or find the XML defining the mentioned style so I can copy it. I've been looking inside the SDK and using this reference: https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/themes.xml but did not succeed.
Any ideas how to make a rounded corners Button BUT keep all the other appearance attributes to their defaults?
The original style uses 9 patches.
If you read THIS document and search for btn_default (beginning at line 1995), you will learn how to make a style that overrides the standard drawables (9 patches).
Then it's just a matter of copying the original artworks to your app's drawable folders and round their corners.
They'll be referred in a StateList drawable, called btn_default_holo_light.xml
If you're using Windows, it's here: C:\Your_Path_To_Eclipse\sdk\platforms\android-XY\data\res\drawable, where XY is 11 to 19 (depending on you minSdkVersion)
And the 9 patches here: C:\Your_Path_To_Eclipse\sdk\platforms\android-XY\data\res\drawable-RES, where XY is 11 to 19 (depending on you minSdkVersion) and RES is the specific dpi resolution (mdpi, as a reference)
How do i get the button styles of the standard next/previous buttons and the gradient backgrounds like in the image below
gradient backgrounds like in the image below
Hi, for gradient backgrounds you can apply below Background Drawable code.
Change color codes according to your needs !
Create gradientbg.xml and paste code given below,
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#817f81"
android:endColor="#ccc9cc"
android:angle="90" />
</shape>
this will make gradient background that you need !
Thanks.
Got it.. extracted both from the AccountsAndSyncSettings.apk :) Its part of the Android system, so i guess there shouldn't be any copyright issues right?
You can add the image to the button using android:drawableRight attribute of <Button>