Добрый день. Есть простая разметка с 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
.
RelativeLayout
, он должен помочь вам в достижении вашей задумки.TextView
иButton
помести воFrameLayout
. А тут как задашь расположениеButton
, и больше оно не поменяется.