Java Code Examples for android.animation.LayoutTransition#enableTransitionType()

The following examples show how to use android.animation.LayoutTransition#enableTransitionType() . 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: DebugView.java    From debugdrawer with Apache License 2.0 7 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private static void enableLayoutTransitions(ViewGroup viewGroup) {
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
		// Remove the status bar color. The DrawerLayout is responsible for drawing it from now on.
		LayoutTransition lt = new LayoutTransition();
		lt.enableTransitionType(LayoutTransition.CHANGING);
		viewGroup.setLayoutTransition(lt);
	} else {
		Timber.w("Error enabling LayoutTransitions, only supported for API14+.");
	}
}
 
Example 2
Source File: PageIndicator.java    From LB-Launcher with Apache License 2.0 7 votes vote down vote up
private void enableLayoutTransitions() {
    LayoutTransition transition = getLayoutTransition();
    transition.enableTransitionType(LayoutTransition.APPEARING);
    transition.enableTransitionType(LayoutTransition.DISAPPEARING);
    transition.enableTransitionType(LayoutTransition.CHANGE_APPEARING);
    transition.enableTransitionType(LayoutTransition.CHANGE_DISAPPEARING);
}
 
Example 3
Source File: PersistentSearchView.java    From PersistentSearchView with Apache License 2.0 7 votes vote down vote up
private void setUpLayoutTransition() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        RelativeLayout searchRoot = (RelativeLayout) findViewById(R.id.search_root);
        LayoutTransition layoutTransition = new LayoutTransition();
        layoutTransition.setDuration(DURATION_LAYOUT_TRANSITION);
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
            // layoutTransition.enableTransitionType(LayoutTransition.CHANGING);
            layoutTransition.enableTransitionType(LayoutTransition.CHANGE_DISAPPEARING);
            layoutTransition.setStartDelay(LayoutTransition.CHANGING, 0);
        }
        layoutTransition.setStartDelay(LayoutTransition.CHANGE_DISAPPEARING, 0);
        mSearchCardView.setLayoutTransition(layoutTransition);
    }
}
 
Example 4
Source File: Workspace.java    From TurboLauncher with Apache License 2.0 7 votes vote down vote up
private void setupLayoutTransition() {
    // We want to show layout transitions when pages are deleted, to close the gap.
    mLayoutTransition = new LayoutTransition();
    mLayoutTransition.enableTransitionType(LayoutTransition.DISAPPEARING);
    mLayoutTransition.enableTransitionType(LayoutTransition.CHANGE_DISAPPEARING);
    mLayoutTransition.disableTransitionType(LayoutTransition.APPEARING);
    mLayoutTransition.disableTransitionType(LayoutTransition.CHANGE_APPEARING);
    setLayoutTransition(mLayoutTransition);
}
 
Example 5
Source File: PageIndicator.java    From TurboLauncher with Apache License 2.0 7 votes vote down vote up
private void enableLayoutTransitions() {
    LayoutTransition transition = getLayoutTransition();
    transition.enableTransitionType(LayoutTransition.APPEARING);
    transition.enableTransitionType(LayoutTransition.DISAPPEARING);
    transition.enableTransitionType(LayoutTransition.CHANGE_APPEARING);
    transition.enableTransitionType(LayoutTransition.CHANGE_DISAPPEARING);
}
 
Example 6
Source File: LabelLayout.java    From mosby with Apache License 2.0 7 votes vote down vote up
private void init() {

    View.inflate(getContext(), R.layout.view_label_layout, this);

    LayoutTransition transition = new LayoutTransition();
    transition.enableTransitionType(LayoutTransition.CHANGING);
    this.setLayoutTransition(transition);

    adapter = new LabelAdapter(getContext());
    popUpWindow = new ListPopupWindow(getContext());
    popUpWindow.setAnchorView(this);
    popUpWindow.setAdapter(adapter);
    popUpWindow.setWidth(DimensUtils.dpToPx(getContext(), 140));
    popUpWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
      @Override public void onDismiss() {
        showLabel();
      }
    });
    popUpWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
      @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        Label label = (Label) adapter.getItem(position);
        if (!label.getName().equals(mail.getLabel())) {
          presenter.setLabel(mail, label.getName());
          popUpWindow.dismiss();
        }
      }
    });

    setOnClickListener(new OnClickListener() {
      @Override public void onClick(View v) {
        loadData(false);
      }
    });
  }
 
Example 7
Source File: LoginFragment.java    From mosby with Apache License 2.0 7 votes vote down vote up
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  super.onViewCreated(view, savedInstanceState);
  loginButton.setMode(ActionProcessButton.Mode.ENDLESS);

  int startDelay = getResources().getInteger(android.R.integer.config_mediumAnimTime) + 100;
  LayoutTransition transition = new LayoutTransition();
  transition.enableTransitionType(LayoutTransition.CHANGING);
  transition.setStartDelay(LayoutTransition.APPEARING, startDelay);
  transition.setStartDelay(LayoutTransition.CHANGE_APPEARING, startDelay);
  loginForm.setLayoutTransition(transition);
}
 
Example 8
Source File: FunControl.java    From Fun with Apache License 2.0 5 votes vote down vote up
public FunControl(Builder builder){
    this.funny = builder.funny;
    this.funnyButton = builder.funnyButton;
    this.funnyContainer = builder.viewGroup;
    this.gravityToExpand = builder.gravityToExpand;
    this.widthToExpand = builder.width;

    LayoutTransition layoutTransition = funny.getLayoutTransition();
    layoutTransition.setDuration(builder.animationDuration);
    layoutTransition.enableTransitionType(LayoutTransition.CHANGING);
}
 
Example 9
Source File: MainActivity.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
	LayoutTransition l = new LayoutTransition();
	l.enableTransitionType(LayoutTransition.CHANGING);
	viewGroup = (ViewGroup) findViewById(R.id.container);
	viewGroup.setLayoutTransition(l);

}
 
Example 10
Source File: Workspace.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
private void setupLayoutTransition() {
    // We want to show layout transitions when pages are deleted, to close the gap.
    mLayoutTransition = new LayoutTransition();
    mLayoutTransition.enableTransitionType(LayoutTransition.DISAPPEARING);
    mLayoutTransition.enableTransitionType(LayoutTransition.CHANGE_DISAPPEARING);
    mLayoutTransition.disableTransitionType(LayoutTransition.APPEARING);
    mLayoutTransition.disableTransitionType(LayoutTransition.CHANGE_APPEARING);
    setLayoutTransition(mLayoutTransition);
}
 
Example 11
Source File: PageIndicator.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
private void enableLayoutTransitions() {
    LayoutTransition transition = getLayoutTransition();
    transition.enableTransitionType(LayoutTransition.APPEARING);
    transition.enableTransitionType(LayoutTransition.DISAPPEARING);
    transition.enableTransitionType(LayoutTransition.CHANGE_APPEARING);
    transition.enableTransitionType(LayoutTransition.CHANGE_DISAPPEARING);
}
 
Example 12
Source File: HyperTextEditor.java    From YCCustomText with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化transition动画
 */
private void setUpLayoutTransitions() {
	mTransition = new LayoutTransition();
	//添加Layout变化监听
	mTransition.addTransitionListener(transitionListener);
	//若向ViewGroup中添加一个ImageView,ImageView对象可以设置动画(即APPEARING 动画形式),
	//ViewGroup中的其它ImageView对象此时移动到新的位置的过程中也可以设置相关的动画(即CHANGE_APPEARING 动画形式)。
	mTransition.enableTransitionType(LayoutTransition.APPEARING);
	//设置整个Layout变换动画时间
	mTransition.setDuration(300);
	layout.setLayoutTransition(mTransition);
}
 
Example 13
Source File: NiboPlacesAutoCompleteSearchView.java    From Nibo with MIT License 5 votes vote down vote up
private void setUpLayoutTransition() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        RelativeLayout searchRoot = (RelativeLayout) findViewById(R.id.search_root);
        LayoutTransition layoutTransition = new LayoutTransition();
        layoutTransition.setDuration(DURATION_LAYOUT_TRANSITION);
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
            // layoutTransition.enableTransitionType(LayoutTransition.CHANGING);
            layoutTransition.enableTransitionType(LayoutTransition.CHANGE_DISAPPEARING);
            layoutTransition.setStartDelay(LayoutTransition.CHANGING, 0);
        }
        layoutTransition.setStartDelay(LayoutTransition.CHANGE_DISAPPEARING, 0);
        mSearchCardView.setLayoutTransition(layoutTransition);
    }
}
 
Example 14
Source File: Workspace.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
private void setupLayoutTransition() {
    // We want to show layout transitions when pages are deleted, to close the gap.
    mLayoutTransition = new LayoutTransition();
    mLayoutTransition.enableTransitionType(LayoutTransition.DISAPPEARING);
    mLayoutTransition.enableTransitionType(LayoutTransition.CHANGE_DISAPPEARING);
    mLayoutTransition.disableTransitionType(LayoutTransition.APPEARING);
    mLayoutTransition.disableTransitionType(LayoutTransition.CHANGE_APPEARING);
    setLayoutTransition(mLayoutTransition);
}
 
Example 15
Source File: CircularButton.java    From GreenBits with GNU General Public License v3.0 4 votes vote down vote up
public CircularButton(Context context, AttributeSet attrs) {
    super(context, attrs);

    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CircularButton);

    setLayoutTransition(new LayoutTransition());

    setRadius(getPx(DEFAULT_RADIUS));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setElevation(getPx(DEFAULT_ELEVATION));
    }

    mLinearLayout = new LinearLayout(context);
    mLinearLayout.setOrientation(LinearLayout.VERTICAL);

    // set selectable background
    final TypedValue typedValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground,
            typedValue, true);
    mLinearLayout.setBackgroundResource(typedValue.resourceId);

    // create button
    mButton = new Button(context);
    mButton.setBackgroundColor(Color.TRANSPARENT);
    mButton.setClickable(false);
    mButton.setPadding((int)getPx(15), mButton.getPaddingTop(), (int)getPx(15),
            mButton.getPaddingBottom());
    final String text = typedArray.getString(R.styleable.CircularButton_text);
    mButton.setText(text);
    mButton.setTextColor(typedArray.getColor(R.styleable.CircularButton_textColor, Color.BLACK));

    // create progressbar
    mProgressBar = new ProgressBar(context);
    mProgressBar.setVisibility(View.GONE);

    // animation transaction
    final LayoutTransition layoutTransition = getLayoutTransition();
    layoutTransition.setDuration(DEFAULT_DURATION);
    layoutTransition.enableTransitionType(LayoutTransition.CHANGING);

    this.setOnClickListener(view -> {
        if (isClickable()) {
            startLoading();
        }
    });

    // set background color animations
    mBackgroundColor = typedArray.getColorStateList(R.styleable.CardView_cardBackgroundColor)
            .getDefaultColor();
    mLinearLayout.setBackgroundColor(mBackgroundColor);
    final ColorDrawable[] color1 = {new ColorDrawable(mBackgroundColor),
            new ColorDrawable(Color.WHITE)};
    mTransStartLoading = new TransitionDrawable(color1);
    final ColorDrawable[] color2 = {new ColorDrawable(Color.WHITE), new
            ColorDrawable(mBackgroundColor)};
    mTransStopLoading = new TransitionDrawable(color2);

    // set progressbar for API < lollipop
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        mProgressBar.setBackgroundColor(Color.WHITE);
        mProgressBar.getIndeterminateDrawable().setColorFilter(
                mBackgroundColor, PorterDuff.Mode.SRC_IN);
    }

    typedArray.recycle();
    mLinearLayout.addView(mButton);
    mLinearLayout.addView(mProgressBar);
    addView(mLinearLayout);
}
 
Example 16
Source File: MainActivity.java    From mosby with Apache License 2.0 4 votes vote down vote up
@Override protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  // Toolbar
  toolbar.inflateMenu(R.menu.search_menu);
  toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
    @Override public boolean onMenuItemClick(MenuItem menuItem) {
      if (menuItem.getItemId() == R.id.search) {
        intentStarter.showSearch(MainActivity.this);
        return true;
      }
      return false;
    }
  });
  drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.drawer_open,
      R.string.drawer_close);
  drawerLayout.setDrawerListener(drawerToggle);
  if (toolbarTitle != null) {
    toolbar.setTitle(toolbarTitle);
  }

  // Check for previous fragments
  detailsFragment = findDetailsFragment();
  labelFragment =
      (MailsFragment) getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG_LABEL);

  if (detailsFragment != null) {
    // details fragment available, so make it visible
    rightPane.setVisibility(View.VISIBLE);
  }

  if (paneContainer != null) {
    // Enable animation
    LayoutTransition transition = new LayoutTransition();
    transition.enableTransitionType(LayoutTransition.CHANGING);
    paneContainer.setLayoutTransition(transition);
  }

  if (labelFragment == null) {
    // First app start, so start with this
    showMails(MailProvider.INBOX_LABEL, true);
  }
}
 
Example 17
Source File: SublimePicker.java    From SublimePicker with Apache License 2.0 4 votes vote down vote up
private void processOptions() {
    if (mOptions.animateLayoutChanges()) {
        // Basic Layout Change Animation(s)
        LayoutTransition layoutTransition = new LayoutTransition();
        if (SUtils.isApi_16_OrHigher()) {
            layoutTransition.enableTransitionType(LayoutTransition.CHANGING);
        }
        setLayoutTransition(layoutTransition);
    } else {
        setLayoutTransition(null);
    }

    mDatePickerEnabled = mOptions.isDatePickerActive();
    mTimePickerEnabled = mOptions.isTimePickerActive();
    mRecurrencePickerEnabled = mOptions.isRecurrencePickerActive();

    if (mDatePickerEnabled) {
        //int[] dateParams = mOptions.getDateParams();
        //mDatePicker.init(dateParams[0] /* year */,
        //        dateParams[1] /* month of year */,
        //        dateParams[2] /* day of month */,
        //        mOptions.canPickDateRange(),
        //        this);
        mDatePicker.init(mOptions.getDateParams(), mOptions.canPickDateRange(), this);

        long[] dateRange = mOptions.getDateRange();

        if (dateRange[0] /* min date */ != Long.MIN_VALUE) {
            mDatePicker.setMinDate(dateRange[0]);
        }

        if (dateRange[1] /* max date */ != Long.MIN_VALUE) {
            mDatePicker.setMaxDate(dateRange[1]);
        }

        mDatePicker.setValidationCallback(this);

        ivRecurrenceOptionsDP.setVisibility(mRecurrencePickerEnabled ?
                View.VISIBLE : View.GONE);
    } else {
        llMainContentHolder.removeView(mDatePicker);
        mDatePicker = null;
    }

    if (mTimePickerEnabled) {
        int[] timeParams = mOptions.getTimeParams();
        mTimePicker.setCurrentHour(timeParams[0] /* hour of day */);
        mTimePicker.setCurrentMinute(timeParams[1] /* minute */);
        mTimePicker.setIs24HourView(mOptions.is24HourView());
        mTimePicker.setValidationCallback(this);

        ivRecurrenceOptionsTP.setVisibility(mRecurrencePickerEnabled ?
                View.VISIBLE : View.GONE);
    } else {
        llMainContentHolder.removeView(mTimePicker);
        mTimePicker = null;
    }

    if (mDatePickerEnabled && mTimePickerEnabled) {
        mButtonLayout.applyOptions(true /* show switch button */,
                mButtonLayoutCallback);
    } else {
        mButtonLayout.applyOptions(false /* hide switch button */,
                mButtonLayoutCallback);
    }

    if (!mDatePickerEnabled && !mTimePickerEnabled) {
        removeView(llMainContentHolder);
        llMainContentHolder = null;
        mButtonLayout = null;
    }

    mCurrentRecurrenceOption = mOptions.getRecurrenceOption();
    mRecurrenceRule = mOptions.getRecurrenceRule();

    if (mRecurrencePickerEnabled) {
        Calendar cal = mDatePickerEnabled ?
                mDatePicker.getSelectedDate().getStartDate()
                : SUtils.getCalendarForLocale(null, Locale.getDefault());

        mSublimeRecurrencePicker.initializeData(mRepeatOptionSetListener,
                mCurrentRecurrenceOption, mRecurrenceRule,
                cal.getTimeInMillis());
    } else {
        removeView(mSublimeRecurrencePicker);
        mSublimeRecurrencePicker = null;
    }

    mCurrentPicker = mOptions.getPickerToShow();
    // Updated from 'updateDisplay()' when 'RecurrencePicker' is chosen
    mHiddenPicker = SublimeOptions.Picker.INVALID;
}
 
Example 18
Source File: ChannelSetupFragment.java    From xipl with Apache License 2.0 4 votes vote down vote up
@Override
public View onCreateView(
        LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(getLayoutResourceId(), container, false);
    // Make sure this view is focused
    view.requestFocus();
    mProgressBar = (ProgressBar) view.findViewById(R.id.tune_progress);
    mScanningMessage = (TextView) view.findViewById(R.id.tune_description);
    mTitle = (TextView) view.findViewById(R.id.tune_title);
    mBadge = (ImageView) view.findViewById(R.id.tune_icon);
    mChannelHolder = view.findViewById(R.id.channel_holder);
    mCancelButton = (Button) view.findViewById(R.id.tune_cancel);

    ListView channelList = (ListView) view.findViewById(R.id.channel_list);
    mAdapter = new ChannelAdapter();
    channelList.setAdapter(mAdapter);
    channelList.setOnItemClickListener(null);

    ViewGroup progressHolder = (ViewGroup) view.findViewById(R.id.progress_holder);
    LayoutTransition transition = new LayoutTransition();
    transition.enableTransitionType(LayoutTransition.CHANGING);
    progressHolder.setLayoutTransition(transition);

    mCancelButton.setOnClickListener(
            new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    finishScan();
                }
            });
    mSyncStatusChangedReceiver = new SyncStatusBroadcastReceiver(getInputId(), this);
    LocalBroadcastManager.getInstance(getActivity())
            .registerReceiver(
                    mSyncStatusChangedReceiver,
                    new IntentFilter(EpgSyncJobService.ACTION_SYNC_STATUS_CHANGED));

    mChannelScanLayout = view;
    setChannelListVisibility(false);
    setBackgroundColor(getResources().getColor(android.R.color.holo_blue_dark));
    return view;
}
 
Example 19
Source File: ChannelSetupFragment.java    From androidtv-sample-inputs with Apache License 2.0 4 votes vote down vote up
@Override
public View onCreateView(
        LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(getLayoutResourceId(), container, false);
    // Make sure this view is focused
    view.requestFocus();
    mProgressBar = (ProgressBar) view.findViewById(R.id.tune_progress);
    mScanningMessage = (TextView) view.findViewById(R.id.tune_description);
    mTitle = (TextView) view.findViewById(R.id.tune_title);
    mBadge = (ImageView) view.findViewById(R.id.tune_icon);
    mChannelHolder = view.findViewById(R.id.channel_holder);
    mCancelButton = (Button) view.findViewById(R.id.tune_cancel);

    ListView channelList = (ListView) view.findViewById(R.id.channel_list);
    mAdapter = new ChannelAdapter();
    channelList.setAdapter(mAdapter);
    channelList.setOnItemClickListener(null);

    ViewGroup progressHolder = (ViewGroup) view.findViewById(R.id.progress_holder);
    LayoutTransition transition = new LayoutTransition();
    transition.enableTransitionType(LayoutTransition.CHANGING);
    progressHolder.setLayoutTransition(transition);

    mCancelButton.setOnClickListener(
            new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    finishScan();
                }
            });
    mSyncStatusChangedReceiver = new SyncStatusBroadcastReceiver(getInputId(), this);
    LocalBroadcastManager.getInstance(getActivity())
            .registerReceiver(
                    mSyncStatusChangedReceiver,
                    new IntentFilter(EpgSyncJobService.ACTION_SYNC_STATUS_CHANGED));

    mChannelScanLayout = view;
    setChannelListVisibility(false);
    setBackgroundColor(getResources().getColor(android.R.color.holo_blue_dark));
    return view;
}
 
Example 20
Source File: CircularButton.java    From green_android with GNU General Public License v3.0 4 votes vote down vote up
public CircularButton(Context context, AttributeSet attrs) {
    super(context, attrs);

    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CircularButton);

    setLayoutTransition(new LayoutTransition());

    setRadius(getPx(DEFAULT_RADIUS));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setElevation(getPx(DEFAULT_ELEVATION));
    }

    mLinearLayout = new LinearLayout(context);
    mLinearLayout.setOrientation(LinearLayout.VERTICAL);

    // set selectable background
    final TypedValue typedValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground,
                                             typedValue, true);
    mSelectableItemBackground = typedValue.resourceId;
    mLinearLayout.setBackgroundResource(mSelectableItemBackground);

    // create button
    mButton = new Button(context);
    mButton.setBackgroundColor(Color.TRANSPARENT);
    mButton.setClickable(false);
    mButton.setPadding((int)getPx(15), mButton.getPaddingTop(), (int)getPx(15),
                       mButton.getPaddingBottom());
    final String text = typedArray.getString(R.styleable.CircularButton_text);
    mButton.setText(text);
    mButton.setTextColor(typedArray.getColor(R.styleable.CircularButton_textColor, Color.BLACK));

    // create progressbar
    mProgressBar = new ProgressBar(context);
    mProgressBar.setVisibility(View.GONE);

    // animation transaction
    final LayoutTransition layoutTransition = getLayoutTransition();
    layoutTransition.setDuration(DEFAULT_DURATION);
    layoutTransition.enableTransitionType(LayoutTransition.CHANGING);

    this.setOnClickListener(view -> {
        if (isClickable()) {
            startLoading();
        }
    });

    // set background color animations
    mBackgroundColor = typedArray.getColorStateList(R.styleable.CardView_cardBackgroundColor)
                       .getDefaultColor();
    final ColorDrawable[] color1 = {new ColorDrawable(mBackgroundColor),
                                    new ColorDrawable(Color.WHITE)};
    mTransStartLoading = new TransitionDrawable(color1);
    final ColorDrawable[] color2 = {new ColorDrawable(mSelectableItemBackground), new
                                    ColorDrawable(mBackgroundColor)};
    mTransStopLoading = new TransitionDrawable(color2);

    // set progressbar for API < lollipop
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        mProgressBar.setBackgroundColor(Color.WHITE);
        mProgressBar.getIndeterminateDrawable().setColorFilter(
            mBackgroundColor, PorterDuff.Mode.SRC_IN);
    }

    typedArray.recycle();

    // get the width set
    final int[] width = new int[] { android.R.attr.layout_width };
    final TypedArray typedArray1 = context.obtainStyledAttributes(attrs, width);
    mLayoutWidth = typedArray1.getLayoutDimension(0, ViewGroup.LayoutParams.WRAP_CONTENT);
    typedArray1.recycle();

    mLinearLayout.addView(mButton);
    mLinearLayout.addView(mProgressBar);
    addView(mLinearLayout);
}