Android линейный макет - как сохранить элемент в нижней части зрения?



у меня есть TextView что я хочу закрепить в нижней части ландшафтной деятельности, используя LinearLayout С вертикально расположенными элементами.



Я android:gravity="bottom" на текстовом представлении, но он по-прежнему любит быть чуть ниже последнего элемента LinearLayout именно то, что я не хочу этого делать.



какие предложения?

591   8  

8 ответов:

извлеките TextView из LinearLayout, затем поместите LinearLayout и TextView внутри RelativeLayout. Добавьте атрибут android:layout_alignParentBottom="true" в поле TextView. Со всеми пространствами имен и другими атрибутами, за исключением вышеуказанного атрибута elided:

<RelativeLayout>
  <LinearLayout>
    <!-- All your other elements in here -->
  </LinearLayout>
  <TextView
    android:layout_alignParentBottom="true" />
</RelativeLayout>

вам придется расширить один из ваших верхних видом, чтобы заполнить оставшееся пространство, установив android:layout_weight="1" на нем. Это подтолкнет ваш последний вид вниз.

вот краткий очерк того, что я имею в виду:

<LinearLayout android:orientation="vertical">
    <View/>
    <View android:layout_weight="1"/>
    <View/>
    <View android:id="@+id/bottom"/>
</LinearLayout>

где каждая из высот вида ребенка "wrap_content" и все остальное "fill_parent".

Я думаю, что это будет идеальное решение:

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

    <!-- Other views -->
    <Space
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>

    <!-- Target view below -->
    <View
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

</LinearLayout>

вы должны поставить параметр тяжести в низу не в textview, но в линейной компоновке. Вот так:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:gravity="bottom|end">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Something"/>
</LinearLayout>
step 1 : create two view inside a linear layout
step 2 : first view must set to android:layout_weight="1"
step 3 : Second view will automatically putted downwards


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

    <View
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1" />

    <Button
    android:id="@+id/btn_health_advice"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>


</LinearLayout>

вы также можете использовать

android:layout_gravity="bottom"

для вашего textview

СДЕЛАЙ ТАК

 <LinearLayout
android:id="@+id/LinearLayouts02"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="bottom|end">

<TextView
    android:id="@+id/texts1"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:layout_weight="2"
    android:text="@string/forgotpass"
    android:padding="7dp"
    android:gravity="bottom|center_horizontal"
    android:paddingLeft="10dp"
    android:layout_marginBottom="30dp"
    android:bottomLeftRadius="10dp"
    android:bottomRightRadius="50dp"
    android:fontFamily="sans-serif-condensed"
    android:textColor="@color/colorAccent"
    android:textStyle="bold"
    android:textSize="16sp"
    android:topLeftRadius="10dp"
    android:topRightRadius="10dp"
   />

</LinearLayout>

попробуй такое

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textViewProfileName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TextView" />

</LinearLayout>

Comments

    Ничего не найдено.