Example usage for android.widget TextView setLayoutParams

List of usage examples for android.widget TextView setLayoutParams

Introduction

In this page you can find the example usage for android.widget TextView setLayoutParams.

Prototype

public void setLayoutParams(ViewGroup.LayoutParams params) 

Source Link

Document

Set the layout parameters associated with this view.

Usage

From source file:com.vonglasow.michael.satstat.RadioSectionFragment.java

protected void showCellLte(CellTowerLte cell) {
    TableRow row = new TableRow(rilLteCells.getContext());
    row.setWeightSum(29);//www. j ava2  s. co  m

    TextView newType = new TextView(rilLteCells.getContext());
    newType.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2));
    newType.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newType.setTextColor(
            rilLteCells.getContext().getResources().getColor(getColorFromGeneration(cell.getGeneration())));
    newType.setText(rilLteCells.getContext().getResources().getString(R.string.smallDot));
    row.addView(newType);

    TextView newMcc = new TextView(rilLteCells.getContext());
    newMcc.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newMcc.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newMcc.setText(formatCellData(rilLteCells.getContext(), "%03d", cell.getMcc()));
    row.addView(newMcc);

    TextView newMnc = new TextView(rilLteCells.getContext());
    newMnc.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newMnc.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newMnc.setText(formatCellData(rilLteCells.getContext(), "%02d", cell.getMnc()));
    row.addView(newMnc);

    TextView newTac = new TextView(rilLteCells.getContext());
    newTac.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 5));
    newTac.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newTac.setText(formatCellData(rilLteCells.getContext(), null, cell.getTac()));
    row.addView(newTac);

    TextView newCi = new TextView(rilLteCells.getContext());
    newCi.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 9));
    newCi.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    if ((mainActivity.prefCid) && (cell.getCi() != CellTower.UNKNOWN)) {
        int eNodeBId = cell.getCi() / 0x100;
        int sectorId = cell.getCi() % 0x100;
        newCi.setText(String.format("%d-%d", eNodeBId, sectorId));
    } else
        newCi.setText(formatCellData(rilLteCells.getContext(), null, cell.getCi()));
    row.addView(newCi);

    TextView newPci = new TextView(rilLteCells.getContext());
    newPci.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newPci.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newPci.setText(formatCellData(rilLteCells.getContext(), null, cell.getPci()));
    row.addView(newPci);

    TextView newDbm = new TextView(rilLteCells.getContext());
    newDbm.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 4));
    newDbm.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newDbm.setText(formatCellDbm(rilLteCells.getContext(), null, cell.getDbm()));
    row.addView(newDbm);

    rilLteCells.addView(row,
            new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}

From source file:fr.cph.chicago.core.adapter.FavoritesAdapter.java

private void handleBusRoute(@NonNull final FavoritesViewHolder holder, @NonNull final BusRoute busRoute) {
    holder.stationNameTextView.setText(busRoute.getId());
    holder.favoriteImage.setImageResource(R.drawable.ic_directions_bus_white_24dp);

    final List<BusDetailsDTO> busDetailsDTOs = new ArrayList<>();

    final Map<String, Map<String, List<BusArrival>>> busArrivals = favoritesData
            .getBusArrivalsMapped(busRoute.getId());
    for (final Entry<String, Map<String, List<BusArrival>>> entry : busArrivals.entrySet()) {
        // Build data for button outside of the loop
        final String stopName = entry.getKey();
        final String stopNameTrimmed = Util.trimBusStopNameIfNeeded(stopName);
        final Map<String, List<BusArrival>> value = entry.getValue();
        for (final String key2 : value.keySet()) {
            final BusArrival busArrival = value.get(key2).get(0);
            final String boundTitle = busArrival.getRouteDirection();
            final BusDirection.BusDirectionEnum busDirectionEnum = BusDirection.BusDirectionEnum
                    .fromString(boundTitle);
            final BusDetailsDTO busDetails = BusDetailsDTO.builder().busRouteId(busArrival.getRouteId())
                    .bound(busDirectionEnum.getShortUpperCase()).boundTitle(boundTitle)
                    .stopId(Integer.toString(busArrival.getStopId())).routeName(busRoute.getName())
                    .stopName(stopName).build();
            busDetailsDTOs.add(busDetails);
        }/*from  w ww. j a  v  a 2 s .c  o m*/

        boolean newLine = true;
        int i = 0;

        for (final Entry<String, List<BusArrival>> entry2 : value.entrySet()) {
            final LinearLayout.LayoutParams containParams = getInsideParams(newLine, i == value.size() - 1);
            final LinearLayout container = new LinearLayout(context);
            container.setOrientation(LinearLayout.HORIZONTAL);
            container.setLayoutParams(containParams);

            // Left
            final LinearLayout.LayoutParams leftParams = new LinearLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            final RelativeLayout left = new RelativeLayout(context);
            left.setLayoutParams(leftParams);

            final RelativeLayout lineIndication = LayoutUtil.createColoredRoundForFavorites(context,
                    TrainLine.NA);
            int lineId = Util.generateViewId();
            lineIndication.setId(lineId);

            final RelativeLayout.LayoutParams destinationParams = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            destinationParams.addRule(RelativeLayout.RIGHT_OF, lineId);
            destinationParams.setMargins(pixelsHalf, 0, 0, 0);

            final String bound = BusDirection.BusDirectionEnum.fromString(entry2.getKey()).getShortLowerCase();
            final String leftString = stopNameTrimmed + " " + bound;
            final SpannableString destinationSpannable = new SpannableString(leftString);
            destinationSpannable.setSpan(new RelativeSizeSpan(0.65f), stopNameTrimmed.length(),
                    leftString.length(), 0); // set size
            destinationSpannable.setSpan(new ForegroundColorSpan(grey5), 0, leftString.length(), 0); // set color

            final TextView boundCustomTextView = new TextView(context);
            boundCustomTextView.setText(destinationSpannable);
            boundCustomTextView.setSingleLine(true);
            boundCustomTextView.setLayoutParams(destinationParams);

            left.addView(lineIndication);
            left.addView(boundCustomTextView);

            // Right
            final LinearLayout.LayoutParams rightParams = new LinearLayout.LayoutParams(
                    LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
            rightParams.setMargins(marginLeftPixel, 0, 0, 0);
            final LinearLayout right = new LinearLayout(context);
            right.setOrientation(LinearLayout.VERTICAL);
            right.setLayoutParams(rightParams);

            final List<BusArrival> buses = entry2.getValue();
            final StringBuilder currentEtas = new StringBuilder();
            for (final BusArrival arri : buses) {
                currentEtas.append(" ").append(arri.getTimeLeftDueDelay());
            }
            final TextView arrivalText = new TextView(context);
            arrivalText.setText(currentEtas);
            arrivalText.setGravity(Gravity.END);
            arrivalText.setSingleLine(true);
            arrivalText.setTextColor(grey5);
            arrivalText.setEllipsize(TextUtils.TruncateAt.END);

            right.addView(arrivalText);

            container.addView(left);
            container.addView(right);

            holder.mainLayout.addView(container);

            newLine = false;
            i++;
        }
    }

    holder.mapButton.setText(activity.getString(R.string.favorites_view_buses));
    holder.detailsButton
            .setOnClickListener(new BusStopOnClickListener(activity, holder.parent, busDetailsDTOs));
    holder.mapButton.setOnClickListener(v -> {
        if (!Util.isNetworkAvailable(context)) {
            Util.showNetworkErrorMessage(activity);
        } else {
            final Set<String> bounds = Stream.of(busDetailsDTOs).map(BusDetailsDTO::getBound)
                    .collect(Collectors.toSet());
            final Intent intent = new Intent(activity.getApplicationContext(), BusMapActivity.class);
            final Bundle extras = new Bundle();
            extras.putString(activity.getString(R.string.bundle_bus_route_id), busRoute.getId());
            extras.putStringArray(activity.getString(R.string.bundle_bus_bounds),
                    bounds.toArray(new String[bounds.size()]));
            intent.putExtras(extras);
            activity.startActivity(intent);
        }
    });
}

From source file:com.saulmm.cui.OrderDialogFragment.java

private View createSelectedTextView(View v) {
    final TextView fakeSelectedTextView = new TextView(getContext(), null, R.attr.selectedTextStyle);

    final String resourceName = getResources().getResourceEntryName(v.getId());

    if (resourceName.startsWith(ID_DATE_SUFFIX))
        fakeSelectedTextView.setText(orderSelection.date);

    else if (resourceName.startsWith(ID_TIME_SUFFIX))
        fakeSelectedTextView.setText(orderSelection.time);

    else if (resourceName.startsWith(ID_SIZE_SUFFIX))
        fakeSelectedTextView.setText(String.valueOf(orderSelection.size));

    fakeSelectedTextView.setLayoutParams(SelectedParamsFactory.startTextParams(v));
    return fakeSelectedTextView;
}

From source file:com.it520.activity.main.wight.SmartTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./*from  w  w w  .j av a2 s. c o m*/
 */
protected TextView createDefaultTabView(CharSequence title) {
    TextView textView = new TextView(getContext());
    textView.setGravity(Gravity.CENTER);
    textView.setText(title);
    textView.setTextColor(tabViewTextColors);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabViewTextSize);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.MATCH_PARENT));

    if (tabViewBackgroundResId != NO_ID) {
        textView.setBackgroundResource(tabViewBackgroundResId);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(tabViewTextAllCaps);
    }

    textView.setPadding(tabViewTextHorizontalPadding, 0, tabViewTextHorizontalPadding, 0);

    if (tabViewTextMinWidth > 0) {
        textView.setMinWidth(tabViewTextMinWidth);
    }

    return textView;
}

From source file:fr.cph.chicago.core.adapter.FavoritesAdapter.java

private void handleStation(@NonNull final FavoritesViewHolder holder, @NonNull final Station station) {
    final int stationId = station.getId();
    final Set<TrainLine> trainLines = station.getLines();

    holder.favoriteImage.setImageResource(R.drawable.ic_train_white_24dp);
    holder.stationNameTextView.setText(station.getName());
    holder.detailsButton.setOnClickListener(v -> {
        if (!Util.isNetworkAvailable(context)) {
            Util.showNetworkErrorMessage(activity);
        } else {/*from  ww w. j  a  v a 2s .  c  om*/
            // Start station activity
            final Bundle extras = new Bundle();
            final Intent intent = new Intent(context, StationActivity.class);
            extras.putInt(activity.getString(R.string.bundle_train_stationId), stationId);
            intent.putExtras(extras);
            activity.startActivity(intent);
        }
    });

    holder.mapButton.setText(activity.getString(R.string.favorites_view_trains));
    holder.mapButton.setOnClickListener(v -> {
        if (!Util.isNetworkAvailable(context)) {
            Util.showNetworkErrorMessage(activity);
        } else {
            if (trainLines.size() == 1) {
                startActivity(trainLines.iterator().next());
            } else {
                final List<Integer> colors = new ArrayList<>();
                final List<String> values = Stream.of(trainLines).flatMap(line -> {
                    final int color = line != TrainLine.YELLOW ? line.getColor()
                            : ContextCompat.getColor(context, R.color.yellowLine);
                    colors.add(color);
                    return Stream.of(line.toStringWithLine());
                }).collect(Collectors.toList());

                final PopupFavoritesTrainAdapter ada = new PopupFavoritesTrainAdapter(activity, values, colors);

                final List<TrainLine> lines = new ArrayList<>();
                lines.addAll(trainLines);

                final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
                builder.setAdapter(ada, (dialog, position) -> startActivity(lines.get(position)));

                final int[] screenSize = Util.getScreenSize(context);
                final AlertDialog dialog = builder.create();
                dialog.show();
                if (dialog.getWindow() != null) {
                    dialog.getWindow().setLayout((int) (screenSize[0] * 0.7), LayoutParams.WRAP_CONTENT);
                }
            }
        }
    });

    Stream.of(trainLines).forEach(trainLine -> {
        boolean newLine = true;
        int i = 0;
        final Map<String, StringBuilder> etas = favoritesData.getTrainArrivalByLine(stationId, trainLine);
        for (final Entry<String, StringBuilder> entry : etas.entrySet()) {
            final LinearLayout.LayoutParams containParam = getInsideParams(newLine, i == etas.size() - 1);
            final LinearLayout container = new LinearLayout(context);
            container.setOrientation(LinearLayout.HORIZONTAL);
            container.setLayoutParams(containParam);

            // Left
            final RelativeLayout.LayoutParams leftParam = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            final RelativeLayout left = new RelativeLayout(context);
            left.setLayoutParams(leftParam);

            final RelativeLayout lineIndication = LayoutUtil.createColoredRoundForFavorites(context, trainLine);
            int lineId = Util.generateViewId();
            lineIndication.setId(lineId);

            final RelativeLayout.LayoutParams destinationParams = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            destinationParams.addRule(RelativeLayout.RIGHT_OF, lineId);
            destinationParams.setMargins(pixelsHalf, 0, 0, 0);

            final String destination = entry.getKey();
            final TextView destinationTextView = new TextView(context);
            destinationTextView.setTextColor(grey5);
            destinationTextView.setText(destination);
            destinationTextView.setLines(1);
            destinationTextView.setLayoutParams(destinationParams);

            left.addView(lineIndication);
            left.addView(destinationTextView);

            // Right
            final LinearLayout.LayoutParams rightParams = new LinearLayout.LayoutParams(
                    LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
            rightParams.setMargins(marginLeftPixel, 0, 0, 0);
            final LinearLayout right = new LinearLayout(context);
            right.setOrientation(LinearLayout.VERTICAL);
            right.setLayoutParams(rightParams);

            final StringBuilder currentEtas = entry.getValue();
            final TextView arrivalText = new TextView(context);
            arrivalText.setText(currentEtas);
            arrivalText.setGravity(Gravity.END);
            arrivalText.setSingleLine(true);
            arrivalText.setTextColor(grey5);
            arrivalText.setEllipsize(TextUtils.TruncateAt.END);

            right.addView(arrivalText);

            container.addView(left);
            container.addView(right);

            holder.mainLayout.addView(container);

            newLine = false;
            i++;
        }
    });
}

From source file:com.near.chimerarevo.fragments.PostFragment.java

private void addTitle(String text, int type) {
    TextView txt = new TextView(getActivity());
    txt.setText(text);/* w  w w  .j  a  v a2s. c o m*/
    txt.setTypeface(Typeface.create("sans-serif-condensed", Typeface.BOLD));
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.setMargins(10, 10, 10, 0);
    txt.setLayoutParams(params);
    txt.setTextIsSelectable(true);

    switch (type) {
    case 1:
        txt.setTextSize(26);
        break;
    case 2:
        txt.setTextSize(24);
        break;
    case 3:
        txt.setTextSize(22);
        break;
    case 4:
        txt.setTextSize(20);
        break;
    case 5:
        txt.setTextSize(18);
        break;
    default:
        break;
    }

    lay.addView(txt);
}

From source file:com.shine.demo.viewpager.smartTabLayout.SmartTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.//from  w ww .j av  a  2 s  .  c om
 */
protected TextView createDefaultTabView(CharSequence title) {
    TextView textView = new TextView(getContext());
    textView.setGravity(Gravity.CENTER);
    textView.setText(title);
    textView.setTextColor(tabViewTextColors);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabViewTextSize);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));

    if (tabViewBackgroundResId != NO_ID) {
        textView.setBackgroundResource(tabViewBackgroundResId);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(tabViewTextAllCaps);
    }

    textView.setPadding(0, tabViewTextHorizontalPadding, 0, tabViewTextHorizontalPadding);

    if (tabViewTextMinWidth > 0) {
        textView.setMinHeight(tabViewTextMinWidth);
    }

    return textView;
}

From source file:com.einzig.ipst2.activities.MainActivity.java

public void setLayoutParamsGraphBars(int height, TextView layout) {
    ViewGroup.LayoutParams params = layout.getLayoutParams();
    params.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, height + 35,
            getResources().getDisplayMetrics());
    Logger.d("HEIGHT: " + params.height);
    layout.setLayoutParams(params);
}

From source file:com.axolotl.yanews.customize.SlidingTabLayout.java

/**
 * tabview. tab view// ww  w  .  j a v  a 2 s  . co  m
 * {@link #setCustomTabView(int, int)}.
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context, null, 0);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, mTab_text_size_sp);
    if (mBold) {
        textView.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
    } else {
        textView.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
    }
    if (mChangeTextColor) {
        textView.setTextColor(mNormalColor);
    }
    textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.MATCH_PARENT));

    if (mBackgroundResource != 0) {
        textView.setBackgroundResource(mBackgroundResource);
    } else {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            // If we're running on Honeycomb or newer, then we can use the Theme's
            // selectableItemBackground to ensure that the View has a pressed state
            TypedValue outValue = new TypedValue();
            getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
            textView.setBackgroundResource(outValue.resourceId);
        }
    }

    //wtf
    //        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    //            // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
    //            textView.setAllCaps(true);
    //        }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, 0, padding, 0);
    return textView;
}

From source file:cz.maresmar.sfm.view.WithExtraFragment.java

@SuppressLint("ClickableViewAccessibility")
@UiThread/*from   ww  w  . j av a2 s.  co  m*/
private void inflateExtraFormat() {
    // Remove old extras from UI
    mExtraLinearLayout.removeAllViewsInLayout();

    mExtraUiBindings = new EditText[mExtrasFormat.size()];

    final LinearLayout.LayoutParams matchWrapParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    // For each extra
    int index = 0;
    for (ExtraFormat extraFormat : mExtrasFormat) {
        //noinspection ConstantConditions
        TextInputLayout textInputLayout = new TextInputLayout(getContext());
        textInputLayout.setLayoutParams(matchWrapParams);
        textInputLayout.setHint(extraFormat.name);

        // If edit text extra
        if (extraFormat.valuesList.length == 0) {
            TextInputEditText editText = new TextInputEditText(getContext());
            editText.setLayoutParams(matchWrapParams);

            mExtraUiBindings[index] = editText;

            textInputLayout.addView(editText);
        } else { // If extra with dropdown
            // Prepare adapter for values
            ArrayAdapter<String> adapter = new ArrayAdapter<>(getContext(),
                    R.layout.support_simple_spinner_dropdown_item, extraFormat.valuesList);

            AutoCompleteTextView autoCompleteTextView = new AutoCompleteTextView(getContext());
            autoCompleteTextView.setLayoutParams(matchWrapParams);
            autoCompleteTextView.setAdapter(adapter);
            // Some UI tweaks to make it look nice
            autoCompleteTextView.setKeyListener(null);
            autoCompleteTextView.setOnTouchListener((v, event) -> {
                ((AutoCompleteTextView) v).showDropDown();
                return false;
            });
            // Set default value
            autoCompleteTextView.setText(extraFormat.valuesList[0]);
            // setText disable other values so I have un-filter them
            adapter.getFilter().filter(null);

            mExtraUiBindings[index] = autoCompleteTextView;

            textInputLayout.addView(autoCompleteTextView);
        }
        mExtraLinearLayout.addView(textInputLayout);

        // Adds optimal extra description
        if (extraFormat.description != null) {
            TextView description = new TextView(getContext());
            description.setText(extraFormat.description);
            TextViewCompat.setTextAppearance(description, R.style.StaticLabel);

            LinearLayout.LayoutParams descriptionLayoutParams = new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
            descriptionLayoutParams.setMargins(getResources().getDimensionPixelSize(R.dimen.content_margin), 0,
                    0, 0);
            description.setLayoutParams(descriptionLayoutParams);

            mExtraLinearLayout.addView(description);
        }

        index++;
    }
}