0

Здраствуйте. помогите пожалуйста. есть такая вот разметка

<TextView
    android:id="@+id/tv_percent_price"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:text=" ___1000"
    android:textColor="@color/colorBlack"
    android:textSize="@dimen/text_size_litle"
    android:textStyle="italic"
    app:layout_marginBottomPercent="20%" />

как изменить значение layout_marginBottomPercent у TextView програмно?

1
  • TextView находится в обвёртке android.support.percent.PercentRelativeLayout 24 мая 2017 в 20:07

1 ответ 1

1
TextView textView = findViewById(R.id.tv_percent_price);
PercentRelativeLayout.LayoutParams params = (PercentRelativeLayout.LayoutParams) textView.getLayoutParams();
// This will currently return null, if it was not constructed from XML.
PercentLayoutHelper.PercentLayoutInfo info = params.getPercentLayoutInfo();
info.marginBottomPercent= 0.60f;
textView.requestLayout();
1

Ваш ответ

Нажимая на кнопку «Отправить ответ», вы соглашаетесь с нашими пользовательским соглашением, политикой конфиденциальности и политикой о куки

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.