Reputation: 179
How can I modify the default title given when you create a Scroll Activity. I was only able to change the title name which I it called "Food Name" in the image. How can I add margin or padding to it and add more titles that have the same properties as you scroll down the "Food Name" gets smaller and smaller.
activity_scrolling.xml
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="545dp"
android:layout_alignParentTop="true"
android:scaleType="fitXY"
android:src="@mipmap/food1"
/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="250dp"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay"
/>
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:src="@mipmap/arrow"
android:id="@id/back_Arrow"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_scrolling">
</include>
</android.support.design.widget.CoordinatorLayout>
This is my activity_scrolling.xml but its isnt located here.
Upvotes: 0
Views: 1062
Reputation: 11
May be it's too late for you, but may be helpful to others. Here is how you can modify default title in a Scroll Activity
private void actionBarSupport() {
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle("Set Title");
}
}
In fragment you can get action bar support like this:
private void actionBarSupport() {
if (((AppCompatActivity) getActivity()).getSupportActionBar() != null) {
((AppCompatActivity) getActivity()).getSupportActionBar().setTitle("");
}
}
Upvotes: 0