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
Related
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.
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 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
Please give me code to design edit text box, button with round corners, etc. Which is shown in the image.
you can use xml drawable and use it as background
first go to drawable directory and create new Drawable Resource file and name it MyRoundButton then copy all this code into it
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:color="#ff66cc"
android:width="2dp"/>
<corners
android:radius="10dp"/>
</shape>
then add this to your Button background
android:background="#drawable/MyRoundButton"
now you can change the corner radius by changing
android:radius="someValue"
and border color by
android:color="#someColor"
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.