Java Code Examples for android.support.v7.widget.Toolbar#setBackgroundResource()

The following examples show how to use android.support.v7.widget.Toolbar#setBackgroundResource() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoginActivity.java    From AccountBook with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreateActivity(@Nullable Bundle savedInstanceState) {
    Toolbar toolbar = initToolbar("");
    toolbar.setNavigationIcon(null);
    toolbar.setBackgroundResource(R.color.colorPrimary);

    // set fragment
    LoginFragment fragment =
            (LoginFragment) getSupportFragmentManager().findFragmentById(R.id.contentFrame);
    if (fragment == null) {
        // Create the fragment
        fragment = LoginFragment.newInstance();
        ActivityUtils.addFragmentToActivity(
                getSupportFragmentManager(), fragment, R.id.contentFrame);
    }

    // create the presenter
    new LoginPresenter(new UserRepository(), fragment);
}
 
Example 2
Source File: RegisterActivity.java    From AccountBook with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreateActivity(@Nullable Bundle savedInstanceState) {
    Toolbar toolbar = initToolbar(UiUtils.getString(R.string.title_register));
    toolbar.setBackgroundResource(R.color.colorPrimary);

    // set fragment
    RegisterFragment fragment =
            (RegisterFragment) getSupportFragmentManager().findFragmentById(R.id.contentFrame);
    if (fragment == null) {
        // Create the fragment
        fragment = RegisterFragment.newInstance();
        ActivityUtils.addFragmentToActivity(
                getSupportFragmentManager(), fragment, R.id.contentFrame);
    }

    // create the presenter
    new RegisterPresenter(new UserRepository(), fragment);
}
 
Example 3
Source File: BaseActivity.java    From Taxi-App-Android-XML with GNU General Public License v3.0 5 votes vote down vote up
public void setTitle(int toolbarId,int titleId, String title, int btnDrawable, int colorBg, int titleColor){
    Toolbar toolbar = (Toolbar) findViewById(toolbarId);
    toolbar.setBackgroundResource(colorBg);
    setSupportActionBar(toolbar);
    TextView pageTitle = (TextView) toolbar.findViewById(titleId);
    pageTitle.setText(title);
    pageTitle.setTextColor(getResources().getColor(titleColor));
    getSupportActionBar().setTitle("");
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeAsUpIndicator(btnDrawable);
}
 
Example 4
Source File: ActorDetailsFragment.java    From Mizuu with Apache License 2.0 4 votes vote down vote up
@Override
public void onViewCreated(final View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    mToolbar = (Toolbar) view.findViewById(R.id.toolbar);
    mToolbar.setBackgroundResource(android.R.color.transparent);
    ViewUtils.setProperToolbarSize(mContext, mToolbar);

    ((MizActivity) getActivity()).setSupportActionBar(mToolbar);

    ((ActionBarActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // This needs to be re-initialized here and not in onCreate()
    mImageThumbSize = getResources().getDimensionPixelSize(R.dimen.horizontal_grid_item_width);
    mImageThumbBackdropSize = getResources().getDimensionPixelSize(R.dimen.horizontal_grid_item_backdrop_width);
    mImageThumbSpacing = getResources().getDimensionPixelSize(R.dimen.image_thumbnail_spacing);

    // Progress layout
    mProgressLayout = view.findViewById(R.id.progress_layout);

    // Details layout
    mDetailsLayout = view.findViewById(R.id.details_area);

    mName = (TextView) view.findViewById(R.id.actor_name);
    mName.setTypeface(mCondensedRegular);

    mPlaceOfBirth = (TextView) view.findViewById(R.id.place_of_birth);
    mPlaceOfBirth.setTypeface(mBold);

    mBirthday = (TextView) view.findViewById(R.id.actor_birthday);
    mBirthday.setTypeface(mMedium);

    mKnownCredits = (TextView) view.findViewById(R.id.actor_known_credits);
    mKnownCredits.setTypeface(mMedium);

    mBiography = (TextView) view.findViewById(R.id.actor_biography);

    mBiography.setBackgroundResource(R.drawable.selectable_background);
    mBiography.setMaxLines(mContext.getResources().getInteger(R.integer.show_details_max_lines));
    mBiography.setTag(true); // true = collapsed
    mBiography.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (((Boolean) mBiography.getTag())) {
                // Animate
                ViewUtils.animateTextViewMaxLines(mBiography, 50); // It seems highly unlikely that there would every be more than 50 lines

                // Reverse the tag
                mBiography.setTag(false);
            } else {
                // Animate
                ViewUtils.animateTextViewMaxLines(mBiography,
                        getResources().getInteger(R.integer.show_details_max_lines));

                // Reverse the tag
                mBiography.setTag(true);
            }
        }
    });
    mBiography.setEllipsize(TextUtils.TruncateAt.END);
    mBiography.setFocusable(true);
    mBiography.setTypeface(mCondensedRegular);

    mPhoto = (ImageView) view.findViewById(R.id.actor_image);
    mBackdrop = (ImageView) view.findViewById(R.id.imageBackground);

    mMovieCards = (HorizontalCardLayout) view.findViewById(R.id.actor_movie_cards);
    mTvCards = (HorizontalCardLayout) view.findViewById(R.id.actor_tv_cards);
    mPhotoCards = (HorizontalCardLayout) view.findViewById(R.id.actor_photo_cards);
    mTaggedPhotoCards = (HorizontalCardLayout) view.findViewById(R.id.actor_tagged_photo_cards);

    mScrollView = (ObservableScrollView) view.findViewById(R.id.observableScrollView);

    final int height = MizLib.getActionBarAndStatusBarHeight(mContext);

    mScrollView.setOnScrollChangedListener(new OnScrollChangedListener() {
        @Override
        public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) {
            ViewUtils.handleOnScrollChangedEvent(
                    getActivity(), view, mPhoto, mActor.getName(),
                    height, t, mToolbar, mToolbarColor);
        }
    });
    mScrollView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            ViewUtils.setLayoutParamsForDetailsEmptyView(mContext, view,
                    mBackdrop, mScrollView, this);
        }
    });

    ViewUtils.updateToolbarBackground(getActivity(), mToolbar, 0, "", mToolbarColor);

    if (mActor == null)
        new ActorLoader(mActorId).execute();
    else
        fillViews();
}