1

Добрый день. Есть простая разметка с TextView и Button.

<LinearLayout
    android:id="@+id/LL2"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:layout_below="@+id/LL"        >


<TextView
    android:id="@+id/selected_item2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
     >
</TextView>       
</LinearLayout>

<LinearLayout
    android:id="@+id/LB"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"                >
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New Button"
    android:id="@+id/button3"
    android:layout_gravity="bottom" />

</LinearLayout>

Button изменяет размер TextView. Как сделать, чтобы button располагался внизу, не деформировался при изменении размера текста, не съезжал вниз, исчезая с экрана, и был как бы наложен поверх TextView?

Полная разметка xml

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

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


<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Кнопка  1"
    android:layout_weight="1"
    android:background="@color/colorPrimary"
    android:textColor="@color/white"
    android:id="@+id/button" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Кнопка 2"
    android:layout_weight="1"
    android:background="@color/colorPrimary"
    android:textColor="@color/white"
    android:id="@+id/button2" />

</LinearLayout>



<LinearLayout
    android:id="@+id/LL2"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:layout_below="@+id/LL"        >


<TextView
    android:id="@+id/selected_item2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
     >
</TextView>
</LinearLayout>

<LinearLayout
    android:id="@+id/LB"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"                >
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New Button"
    android:id="@+id/button3"
    android:layout_gravity="bottom" />

</LinearLayout>

Первые 2 кнопки находятся сверху под actionbar. Но проблема лишь с тем, что сверху описал - с button3 и textview.

3
  • посмотрите в сторону RelativeLayout, он должен помочь вам в достижении вашей задумки.
    – ermak0ff
    28 июл 2016 в 9:34
  • TextView и Button помести во FrameLayout. А тут как задашь расположение Button, и больше оно не поменяется.
    – Frozik6k
    28 июл 2016 в 9:44
  • Всем спасибо. RelativeLayout помогло. Уверен, что способ Maksim Ponomarev тоже рабочий. Благодарю. 28 июл 2016 в 10:09

0

Ваш ответ

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

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