A
A
Alexander Tipugin2011-04-14 12:12:29
Android
Alexander Tipugin, 2011-04-14 12:12:29

Custom UI in Android

I've been digging a development theme for Androyd for about a week. The following question arose - if I suppose I had to radically change the appearance, for example, of a button - (Button) - how can this be done? It means that I want to use my images and so on.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
Roman Abdulmanov, 2011-04-14
@atipugin

For a Button, you can define your own look by setting images for its different states (pressed / in focus / not pressed):

<Button android:id="@+id/my_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="My Text"
    android:background="@drawable/mybutton_background"/>

Where in drawable/mybutton_background are instructions on which images to use, for example:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="true" 
    	  android:state_pressed="false" 
    	  android:drawable="@android:drawable/grey_button_background_focus_blue" />
    <item android:state_focused="true" 
    	  android:state_pressed="true"
    	  android:drawable="@android:drawable/grey_button_background_pressed_blue" />
    <item android:state_focused="false" 
    	  android:state_pressed="true"
    android:drawable="@android:drawable/grey_button_background_pressed_blue" />
    <item android:drawable="@android:drawable/grey_button_background_normal" />
</selector>

K
Khurshed Nurmatov, 2011-04-14
@Hoorsh

Don't forget to dig towards the 9-patch as well. There is an article on habré

O
optemist, 2011-04-14
@optemist

Perhaps this will be useful to you.

R
Roman, 2011-04-14
@WNeZRoS

Developer.android.com has a guide for creating custom components

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question