четверг, 19 января 2012 г.

Удобная панелька для перехода "Далее" по приложению

Вот такая панель:




В решении я делаю следующие:

1) создаю LinearLayout c 3-мя елементами
2) переопределяю стиль кнопки.

Код main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:background="#5D8AA8"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:paddingTop="2dip"
android:paddingBottom="1dip">

<Button
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Назад"
android:textColor="#eee"
android:background="@drawable/myb_states"
android:drawableLeft="@drawable/ic_arrow_left"
android:drawablePadding="10dip" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="текст на панели"
android:textStyle="bold"
android:textColor="#eee"
android:gravity="center"
android:layout_weight="1" />

<Button
android:id="@+id/Button02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Далее"
android:drawableRight="@drawable/ic_arrow_right"
android:drawablePadding="10dip"
android:textColor="#eee"
android:background="@drawable/myb_states"
/>
</LinearLayout>

Код myb_states.xml:

<?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="@drawable/myb_focused" />
    <item android:state_focused="true"
     android:state_pressed="true"
          android:drawable="@drawable/myb_active" />
    <item android:state_focused="false"
     android:state_pressed="true"
     android:drawable="@drawable/myb_active" />
    <item android:drawable="@drawable/myb_inactive" />
</selector>

myb_active.png :


 myb_focused.png :
 myb_inactive.png :


ic_arrow_right.png :

ic_arrow_left.png : 








Комментариев нет:

Отправить комментарий