stepstone-tech / android-material-stepper

This library allows to use Material steppers inside Android applications.
Apache License 2.0
1.78k stars 262 forks source link

Hide top title #278

Closed isoubelet closed 5 years ago

isoubelet commented 5 years ago

Hi team, Just wanted to kindly ask for your help here: I would need to hide the bar that appears at the very top (I guess that is meant to display a title) and only keep the main one, at the bottom.

Is that currently possible?

Many thanks

image

zawadz88 commented 5 years ago

Hi @isoubelet, I don't recognise this bar as being the part of the library TBH - the arrows don't look familiar. Could you share your code/layout file, please?

isoubelet commented 5 years ago

Hi @zawadz88, Thanks for your prompt answer — Well, that's strange, it's maybe due to something in my code then. The code itself is pretty simple:

Layout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <com.stepstone.stepper.StepperLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/stepperLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:ms_tabNavigationEnabled="false"
        app:ms_stepperFeedbackType="none"
        app:ms_stepperType="progress_bar" />

</RelativeLayout>

Activity

public class StepperActivity extends AppCompatActivity {

    private StepperLayout mStepperLayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_bet);
        mStepperLayout = findViewById(R.id.stepperLayout);
        mStepperLayout.setAdapter(new MyStepperAdapter(getSupportFragmentManager(), this));
    }
}

Adapter

public class MyStepperAdapter extends AbstractFragmentStepAdapter {

    private static final String CURRENT_STEP_POSITION_KEY = "position";

    public MyStepperAdapter(FragmentManager fm, Context context) {
        super(fm, context);
    }

    @Override
    public Step createStep(int position) {
        final StepFragmentSample step = new StepFragmentSample();
        Bundle b = new Bundle();
        b.putInt(CURRENT_STEP_POSITION_KEY, position);
        step.setArguments(b);
        return step;
    }

    @Override
    public int getCount() {
        return 3;
    }

}

I will search for other potential causes.

Many thanks for your help.

zawadz88 commented 5 years ago

Could you check the actual view hierarchy with Layout Inspector from Android Studio?

isoubelet commented 5 years ago

Yes, sure. I modified heights so the bar appears next to the stepper's bottom bar and it is easier to get everything in the area. Here we go:

image

zawadz88 commented 5 years ago

Looking at that View hierarchy it looks that's actually the content of the step. So in your case StepFragmentSample. Could you check the layout of that fragment?

isoubelet commented 5 years ago

Really good catch, @zawadz88 My mistake: I am actually testing several "steppers" and there is one that includes a layout called step, since I copy-paste the example that comes in the README, particularly StepFragmentSample, then the other layout was automatically imported (inflated) and I never noticed that.

Many thanks for your help, highly appreciated.