0

есть два LinearLayout buttonLinearLayout и nextButtonLinearLayout. На данный момент они находятся один под другим. В коде в зависимости от надобности один скрывается другой появляется таким вот кодом.

nextButtonLinearLayout.setVisibility(LinearLayout.INVISIBLE);
buttonLinearLayout.setVisibility(LinearLayout.VISIBLE);

Но есть проблема в том, что кнопки находятся на разных местах по высоте и получается некрасивый переход. Просьба подсказать, как сделать так чтобы кнопки были на одном уровне.

Код активности ниже.

<TextView
    android:id="@+id/jokeTextView"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_gravity="center_horizontal"
    android:layout_weight="1"
    android:gravity="center"
    android:textSize="@dimen/joke_text_view" />

<LinearLayout
    android:id="@+id/buttonLinearLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <Button
        android:id="@+id/yesButton"
        style="?attr/buttonStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/yesButton" />

    <Button
        android:id="@+id/noButton"
        style="?attr/buttonStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/noButton" />

</LinearLayout>

<LinearLayout
    android:id="@+id/nextButtonLinearLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <Button
        android:id="@+id/nextButton"
        style="?attr/buttonStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/nextButton" />

</LinearLayout>

1 ответ 1

3

Попробуйте так, INVISIBLE делает просто невыдимым, а GONE буд-то "убирает"

 nextButtonLinearLayout.setVisibility(LinearLayout.GONE);
 buttonLinearLayout.setVisibility(LinearLayout.VISIBLE);
1

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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