Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7675053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:52:30+00:00 2026-05-31T16:52:30+00:00

I have a wizard in my app where users can go back and forward

  • 0

I have a wizard in my app where users can go back and forward between activities using “Back” and “Next” buttons. These buttons are the same for every activity in the wizard and are defined in their own xml layout which gets included in the the layout for each of the activities. They have a state list as their background which usually works, except once in awhile this happens:

Expected:

Expected

Actual:

Actual

Button Definition – add_nav_buttons.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/rlAddNav"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        orientation="horizontal">
        <Button
            android:id="@+id/bAddBack"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:background="@drawable/b_add_nav_button"
            android:text="@string/bBack">
        </Button>
        <Button
            android:id="@+id/bAddNext"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:background="@drawable/b_add_nav_button"
            android:text="@string/bNext">
        </Button>
    </LinearLayout>
</RelativeLayout>

Include Example – some_activity_layout.xml

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/rlAddMain"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <!-- OTHER STUFF -->

    <include
        android:id="@+id/NavButtons"
        layout="@layout/add_nav_buttons"
        android:layout_marginTop="-50dp"
        android:layout_alignParentBottom="true">
    </include>
</RelativeLayout> 

StateList Definition – b_add_nav_button.xml

<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_enabled="false">
        <shape>
            <gradient
                android:startColor="#C7C7C7"
                android:endColor="#8B8B8B"
                android:angle="270">
            </gradient>
            <stroke
                android:width="1dp"
                android:color="#8B8B8B"> 
            </stroke>
            <padding
                android:left="10dp"
                android:right="10dp"
                android:top="10dp"
                android:bottom="10dp">
            </padding>
        </shape>
    </item>
    <item android:state_pressed="true" >
        <shape>
            <solid
                android:color="#FFA319" />
            <padding
                android:left="10dp"
                android:right="10dp"
                android:top="10dp"
                android:bottom="10dp" />
        </shape>
    </item>
    <item>
        <shape>
            <gradient
                android:startColor="#4F4FB2"
                android:endColor="#24248F"
                android:angle="270">
            </gradient>
            <stroke
                android:width="1dp"
                android:color="#24248F"> 
            </stroke>
            <padding
                android:left="10dp"
                android:right="10dp"
                android:top="10dp"
                android:bottom="10dp">
            </padding>
        </shape>
    </item>
</selector>

I am completely baffled, any help would be much appreciated. Just to re-iterate, most of the time the expected behaviour happens, just once in awhile the background fails to draw.

I should also add that the buttons still functionally work like they’re supposed to.

Edit

I added some debug statements and managed to reproduce. Apparently Android sometimes interprets b_add_bav_button.xml as a ColorDrawable instead of a StateListDrawable. I tried pulling the shapes out of the state list into their own xml files, no dice. I’m still equally baffled.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:52:31+00:00Added an answer on May 31, 2026 at 4:52 pm

    Android thought I was using a ColorDrawable instead of a StateListDrawable which resulted in the behaviour mentioned above. I still have no idea why, but it had something to do with screen orientation (it was reproducible by starting activity, popping activity, rotating screen, and starting activity again).

    My work around was to pull the <shape>’s out of the xml selector and instead build a
    StateListDrawable programmatically like so:

    StateListDrawable d = new StateListDrawable();
    d.addState(new int[]{ android.R.attr.state_pressed, android.R.attr.state_enabled }, 
               this.getResources().getDrawable(R.drawable.b_add_nav_button_pressed));
    d.addState(new int[]{ -android.R.attr.state_enabled },
               this.getResources().getDrawable(R.drawable.b_add_nav_button_disabled));
    d.addState(new int[]{ android.R.attr.state_enabled },
               this.getResources().getDrawable(R.drawable.b_add_nav_button_normal));
    bNext.setBackgroundDrawable(d);
    

    There is a lot of weirdness going on, but I seem to have it working.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can one have more than a Wizard control on the same page without
I have a fairly straight-forward navigation based app. It is like a wizard in
I have a wizard app where user goes thru 8-10 activities but might drop
I have an MFC app which is wizard based. The App asks a user
I have an app that I'm writing a little wizard for. It automated a
We have a Visual Studio Wizard written using the DTE environment to automatically generate
I have created an Item Template using the Export Template wizard. I opened up
Hi Sitepoint wizard people, Say we have an admin application that has multiple users
I have converted an iPhone application using the wizard like thing in XCode into
I have a rails app where users share specific kinds of photos. Currently the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.