Skip to content Skip to sidebar Skip to footer

Hiding Scrolling Activity Title In Android Studio

I have created a Scrolling activity. I want to hide this activity title (Banglalink Latest Offers). But I want to show activity title at this stage (Banglalink Latest Offers). Is

Solution 1:

A bit late but I think this might help someone looking for a solution for this, you can simply set the text color to transparent. Just add the below style to your styles.xml:

<stylename="ToolBarTheme"><itemname="android:textColor">@android:color/transparent</item></style>

and add the following attribute to your CollapsingToolbarLayout:

app:expandedTitleTextAppearance="@style/ToolBarTheme"

Solution 2:

Simply add this line to CollapsingToolbarLayout in your xml file:

app:titleEnabled="false"

Solution 3:

Your best bet it to convert to a normal activity (with a scrollview as a child), start with the actionbar hidden (using the hide() call below (put it inside onCreate()).

Then put the coloured backgroiund at top of screen inside scrollview. Finally, you can programmatically toggle between hiding your title (and actionbar), but showing your header background (or vice versa) when needed by adding a horizontal scroll listener/observer.

The listener will toggle the actionbar and header view depending on how far the user has scrolled down.

E.g:

Add observer inside onStart():

 hsv.getViewTreeObserver().addOnScrollChangedListener(
      new ViewTreeObserver.OnScrollChangedListener() 
      {  @Override public void onScrollChanged() 
         {
            Log.i(TAG,"scroll:"+hsv.getScrollX());}});
            // todo adjust scrollx value to decide on hide or show call:
            if (hsv.getScrollX() > 100)             
                getActionBar().show();
                mHeaderLayoutView.setVisibility(View.GONE);
            else 
                getActionBar().hide();
                mHeaderLayoutView.setVisibily(View.VISIBLE)

            ...

Note: hsv is a HorizontalScrollView works.

Note, if your are using the support libraries (E.g. you activity class extends AppCompatActivity), the code would change to:

getSupportActionBar().hide();

Im not sure if the getScrollX is in pixels or dp (job for you to research).

Hope this helps!

Solution 4:

<resources><dimenname="app_bar_height">180dp</dimen><dimenname="fab_margin">16dp</dimen><dimenname="text_margin">16dp</dimen><!-- Default screen margins, per the Android Design guidelines. --><dimenname="activity_horizontal_margin">16dp</dimen><dimenname="activity_vertical_margin">16dp</dimen><dimenname="appbar_padding_top">8dp</dimen></resources>

This must be your dimens.xml file. If you reduce the app_bar_height to 120dp or close... the text will be invisible. I dont know how to bring it back after collapse

Solution 5:

This is working for me:

CollapsingToolbarLayouttoolbarLayout= (CollapsingToolbarLayout) 
                                findViewById(R.id.toolbar_layout);
toolbarLayout.setTitle(" ");

Post a Comment for "Hiding Scrolling Activity Title In Android Studio"