Есть несколько кнопок Linearlayout по центру (xml), и я хочу добавить одну textView, чтобы она располагалась в самом низу экрана, чтобы другие элементы не перетаскивались от этого вверх и не меняли свое местоположение впринципе. Помогите пожалуйста, буду очень благодарен.
2 ответа
Не знаю, что вам нужно, но при таком раскладе textView2
будет всегда оставаться снизу.
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/textView2"
android:fitsSystemWindows="true"
>
<include
layout="@layout/toolbar_collapsing"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:id="@+id/linearBus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="@+id/cv_av_2"
style="?attr/myCardViewStyle"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/detail_1"
style="@style/textMainSchedule"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textAllCaps="true"
android:textColor="?attr/colorAccent"
android:textSize="24sp" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:text="TextView" />
Самый простой и незамысловатый вариант:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
//ваши другие view
</FrameLayout>
<TextView
android:layout_width="match_parent"
android:maxLines="1" //чтобы при увеличении числа строк TV не увеличивался в размерах
android:layout_height="wrap_content" />
</LinearLayout>