I want to create something like this images and i have a lot of drawables like this one. Please help. thanks
enter image description here
You can use below code for making border :
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid
android:color="#color/white"/>
<stroke
android:width="1dp"
android:color="#color/app_color"/>
<corners
android:radius="#dimen/dp_10"/>
</shape>
And use imageView for TopLeft and BottomRigth corners. For making rounded shape of image you may also use cardView.
Related
On Android.
I am looking for a way to create a background drawable which will give the image a transparent gradient.
Aiming to have the top of the image slightly less opaque than the original image and fade down to a completely transparent image.
Would like to do this as part of a drawable so I can apply to any of the items within a RecyclerView during run time.
Be grateful for any help if anyone has any idea.
Example - Drawable
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/your_image"/>
<item>
<shape android:shape="rectangle">
<gradient android:startColor="#00efefef"
android:endColor="#ffefefef"
android:angle="270"
android:type="linear"/>
</shape>
</item>
</layer-list>
I am doing such type of project, in my project, i want to change the color of only a portion of my picture, for example when I click on a button I want the blue become green, i want to know if there is any way to do that or it's impossible
To achieve the above feature, you could define a shape and place it above the button and then change the color onClick. A simple example is:
shape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners
android:topLeftRadius="4dp"
android:topRightRadius="4dp"
android:bottomRightRadius="4dp"
android:bottomLeftRadius="4dp">
</corners>
<solid
android:color="#4848ea">
</solid>
</shape>
Now change the color of the shape using the following code.
GradientDrawable Shape = (GradientDrawable)shape.getBackground();
Shape.setColor(Color.GREEN);
Place the above code within the button onClick.
I want to edit a TextView widget in such way that it looks like a message box (see the picture)1. However, right now I only have a rectangle shape with rounded corners, but I want it to look exactly like the picture.
Code:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<corners android:radius="10dp"/>
<solid android:color="#FFFFFF"/>
</shape>
</item>
</selector>
use 9-patch image provided by android studio itself. because the edittext scale according to the text entered by user. 9-patch can scale the image properly. But you have to first create the image using photoshop or some other software. google it. you will find.
tutorial for 9 patch
I want to create an ImageView like this one. I know it's a combination of a rectangle and a triangle shape,
but I really don't know how to implement it.
Is it possible in XML?. Does layer-list seem to help in this case?. I would like to have some example drawable xml codes
In XML you can create:
rectangle
oval
ring
line
gradient
and more
Image like this difficult or impossible create in XML, try use vector (.svg) files
Convert .PNG to .SVG
P.S. you can create image like this:
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="#EC6118"/>
<corners android:bottomRightRadius="7dp"
android:bottomLeftRadius="0.1dip"
android:topLeftRadius="7dip"
android:topRightRadius="0.1dp"/>
</shape>
</item>
</selector>
I want to show edit text box with two sides. so, for that i need to create a rectangle shape with two sides. PLease help some one.
create a drawable under drawable folder and add the belwow contents (border.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<solid android:color="#color/black" />
<stroke android:width="1dip" android:color="#color/white"/>
</shape>
Now set the Background of the EditText to this draw able like :
android:background="#drawable/border"
I think the best way to do this is to create a 9-patch in PhotoShop with required border sides... there are also several other ways... depends on your design.