Transparency in a background of a View in android can be achieved in two ways. 1. By providing a transparent image. 2. By providing an XML that has as shape with end, starting and middle color. This is a sample XML that creates a transparency. bg_gradiant.xml [xml] <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape> <gradient android:endColor ="#FFFFFF" android:startColor="#AA2F1701"… Read More »
Hello everyone… Today I will show you how to create a simple widget in android? First create a new project and name it “Widget1” and name the activity “WidgetDemo1“. Actually we dont need the activity class here. You can delete it and delete the corresponding entry of it from the AndroidManifest file also. Now we will make the… Read More »
In the previous post I have showed how to create gradient buttons in android using XML. This is how we do this in java code. [java] Button b = (Button)findViewById(R.id.Button01); b.getBackground().setColorFilter(0xFF00FF00, PorterDuff.Mode.MULTIPLY); [/java] This is another method of applying gradiant. [java] b.getBackground().setColorFilter(new LightingColorFilter(0xFF00FF00, 0xFFAA0000)); [/java] Please leave your valuable comments.
In android with shapes we can create beautiful layouts. Lets look at an example. Create an xml named “gradient.xml” in your drawable folder and copy this code into it. [xml] <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:angle="0" android:startColor="#000000" android:endColor="#000000" android:centerColor="#97CF4D" /> </shape> [/xml] Now the main layout file main.xml [xml] <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/LinearLayout01" android:orientation="vertical"… Read More »
Beautifying our applications is one of the main features of your application’s success. In ANDROID there are many possible ways to do this. For eg. We need to have different colors for our buttons, However we can give backgrounds for buttons and all. But we can do many by using our custom xml files, like changing colors on… Read More »