开发者

Android GUI Help: How to Create custom buttons

开发者 https://www.devze.com 2023-02-25 01:47 出处:网络
I was wondering how you can create buttons like the ones at t开发者_开发问答he bottom of the screen and the home button at the top?

I was wondering how you can create buttons like the ones at t开发者_开发问答he bottom of the screen and the home button at the top?

Android GUI Help: How to Create custom buttons


Quite hard to understand if you have doubts about button design and states or button position. If it's a design issue, you should create your button states on your favorite software, as example, photoshop. Then, in your android layouts you point your button background src to a drawable XML containing all button states.

Example XML for button:

    <Button android:id="@+id/back"
            android:layout_width="184px" android:layout_height="44px"
            android:background="@+drawable/back" />

After this, you need your custom picture for the button, and the button XML on your drawables folder, here's the XML you need for your button:

    <?xml version="1.0" encoding="utf-8"?>
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
     <item android:state_pressed="true"
           android:drawable="@drawable/button_pressed" /> <!-- pressed -->
     <item android:state_focused="true"
           android:drawable="@drawable/button_focused" /> <!-- focused -->
     <item android:drawable="@drawable/button_normal" /> <!-- default -->
 </selector>

Follow up on: http://developer.android.com/reference/android/widget/ImageButton.html


The title bar you mentioned about is called "Action Bar"

You can learn how to implement it here:

  • http://android.cyrilmottier.com/?p=274
  • https://github.com/johannilsson/android-actionbar/

Regards.

0

精彩评论

暂无评论...
验证码 换一张
取 消