2016-07-23 2 views
0
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.MainActivity" 
    android:weightSum="4" 
    android:orientation="vertical" 
    android:background="#EDEDED"> 
    <LinearLayout android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:background="#db4437" 
     android:weightSum="2" 
     android:orientation="vertical" 
     > 

     <ImageView 
      android:id="@+id/imgHeader" 
      android:layout_height="80dp" 
      android:layout_width="200dp" 
      android:src="@drawable/cruise" 
      android:layout_gravity="center_horizontal|center_vertical" 
      android:layout_weight="1"/> 
     <TextView 
      android:layout_weight="1" 
      android:layout_height="wrap_content" 
      android:layout_width="wrap_content" 
      android:text="Header" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:textColor="@android:color/white" 
      android:singleLine="true" 
      android:textAlignment="center" 
      android:layout_gravity="center_horizontal|center_vertical" 
      /> 
     </LinearLayout> 



    <LinearLayout android:layout_weight="1" 
     android:layout_width="match_parent" 
     android:layout_height="32dp" 
     android:layout_marginTop="-30dp" 
     android:background="@android:color/white" 
     android:orientation="vertical" 
     android:weightSum="3" 
     android:layout_marginLeft="30dp" 
     android:layout_marginRight="30dp" 
     android:elevation="30dp" 
     > 

     <EditText 
      android:layout_weight="0.5" 
      android:layout_height="wrap_content" 
      android:layout_width="match_parent" 
      style="@style/textbox" 
      android:textColor="@android:color/black" 
      android:drawableStart="@drawable/user_male" 
      android:drawableLeft="@drawable/user_male" 
      android:adjustViewBounds="true" 
      android:maxHeight="10dp" 
      android:maxWidth="10dp" 
      android:scaleType="fitCenter" 
      android:hint="Email..." /> 
     <EditText 
      android:layout_weight="0.5" 
      android:layout_height="wrap_content" 
      android:layout_width="match_parent" 
      style="@style/textbox" 
      android:textColor="@android:color/black" 
      android:drawableStart="@drawable/user_male" 
      android:drawableLeft="@drawable/user_male" 
      android:adjustViewBounds="true" 
      android:maxHeight="20dp" 
      android:maxWidth="20dp" 
      android:hint="Password..." /> 

     <LinearLayout android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.3" 
      android:orientation="horizontal" 
      android:background="#EDEDED" 
      android:weightSum="2" 
      > 

      <Button android:layout_height="wrap_content" 
       android:layout_width="wrap_content" 
       android:textColor="#CCCCCC" 
       android:text="Forgot password?" 
       android:layout_marginLeft="20dp" 
       android:background="@android:color/transparent"/> 
      <View 
       android:layout_width="0dp" 
       android:layout_height="0dp" 
       android:layout_weight="1" 
       android:background="#EDEDED" 
       /> 
      <Button 
       android:layout_weight="1" 
       android:layout_height="wrap_content" 
       android:layout_width="wrap_content" 
       android:text="Login" 
       android:layout_marginRight="10dp" 
       android:background="#db4437"/> 
      </LinearLayout> 
    </LinearLayout> 
    <LinearLayout android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1.5" 
     android:orientation="horizontal" 
     android:id="@id/bottom" 
     > 

     <ImageView 
      android:id="@+id/bus_ruta1" 
      android:layout_width="wrap_content" 
      android:layout_height="30dp" 
      android:layout_gravity="center" 
      android:layout_weight="1" 
      android:gravity="center|bottom" 

      android:scaleType="fitEnd" 
      android:src="@drawable/vai_one" 
      /> 

     <ImageView 
      android:id="@+id/bus_ruta2" 
      android:layout_width="wrap_content" 
      android:layout_height="30dp" 
      android:layout_gravity="center" 
      android:layout_weight="1" 
      android:gravity="center|bottom" 
      android:scaleType="fitEnd" 
      android:src="@drawable/vai_twi" /> 

     <ImageView 
      android:id="@+id/bus_ruta3" 
      android:layout_width="wrap_content" 
      android:layout_height="30dp" 
      android:layout_gravity="center" 
      android:layout_weight="1" 
      android:gravity="center|bottom" 
      android:scaleType="fitEnd" 
      android:src="@drawable/vai_three" /> 

     </LinearLayout> 


</LinearLayout> 

Im, используя следующий код Последняя линейная компоновка содержит три изображения, и я хочу, чтобы эти изображения были в нижней части экрана, но они не фиксируются внизу. Как я могу разобраться в этом?Невозможно заставить изображения быть внизу

+0

Гравитация не делает то, что вы думаете. Попробуйте использовать RelativeLayout –

ответ

1

Возможные продублируйте из How to align views at the bottom of the screen?

попробовать с помощью RelativeLayout. Попробуй это.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.MainActivity" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="#EDEDED" 
     android:orientation="vertical" 
     android:weightSum="4" 
     tools:context="com.MainActivity" > 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:background="#db4437" 
      android:orientation="vertical" 
      android:weightSum="2" > 

      <ImageView 
       android:id="@+id/imgHeader" 
       android:layout_width="200dp" 
       android:layout_height="80dp" 
       android:layout_gravity="center_horizontal|center_vertical" 
       android:layout_weight="1" 
       android:src="@drawable/cruise" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_horizontal|center_vertical" 
       android:layout_weight="1" 
       android:singleLine="true" 
       android:text="Header" 
       android:textAlignment="center" 
       android:textAppearance="?android:attr/textAppearanceLarge" 
       android:textColor="@android:color/white" /> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="32dp" 
      android:layout_marginLeft="30dp" 
      android:layout_marginRight="30dp" 
      android:layout_marginTop="-30dp" 
      android:layout_weight="1" 
      android:background="@android:color/white" 
      android:elevation="30dp" 
      android:orientation="vertical" 
      android:weightSum="3" > 

      <EditText 
       style="@style/textbox" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.5" 
       android:adjustViewBounds="true" 
       android:drawableLeft="@drawable/user_male" 
       android:drawableStart="@drawable/user_male" 
       android:hint="Email..." 
       android:maxHeight="10dp" 
       android:maxWidth="10dp" 
       android:scaleType="fitCenter" 
       android:textColor="@android:color/black" /> 

      <EditText 
       style="@style/textbox" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.5" 
       android:adjustViewBounds="true" 
       android:drawableLeft="@drawable/user_male" 
       android:drawableStart="@drawable/user_male" 
       android:hint="Password..." 
       android:maxHeight="20dp" 
       android:maxWidth="20dp" 
       android:textColor="@android:color/black" /> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.3" 
       android:background="#EDEDED" 
       android:orientation="horizontal" 
       android:weightSum="2" > 

       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="20dp" 
        android:background="@android:color/transparent" 
        android:text="Forgot password?" 
        android:textColor="#CCCCCC" /> 

       <View 
        android:layout_width="0dp" 
        android:layout_height="0dp" 
        android:layout_weight="1" 
        android:background="#EDEDED" /> 

       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginRight="10dp" 
        android:layout_weight="1" 
        android:background="#db4437" 
        android:text="Login" /> 
      </LinearLayout> 
     </LinearLayout> 
    </LinearLayout> 

    <LinearLayout 
     android:id="@id/bottom" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1.5" 
     android:layout_alignParentBottom="true" 
     android:orientation="horizontal" > 

     <ImageView 
      android:id="@+id/bus_ruta1" 
      android:layout_width="wrap_content" 
      android:layout_height="30dp" 
      android:layout_gravity="center" 
      android:layout_weight="1" 
      android:gravity="center|bottom" 
      android:scaleType="fitEnd" 
      android:src="@drawable/vai_one" /> 

     <ImageView 
      android:id="@+id/bus_ruta2" 
      android:layout_width="wrap_content" 
      android:layout_height="30dp" 
      android:layout_gravity="center" 
      android:layout_weight="1" 
      android:gravity="center|bottom" 
      android:scaleType="fitEnd" 
      android:src="@drawable/vai_twi" /> 

     <ImageView 
      android:id="@+id/bus_ruta3" 
      android:layout_width="wrap_content" 
      android:layout_height="30dp" 
      android:layout_gravity="center" 
      android:layout_weight="1" 
      android:gravity="center|bottom" 
      android:scaleType="fitEnd" 
      android:src="@drawable/vai_three" /> 
    </LinearLayout> 

</RelativeLayout> 

Здесь android:layout_alignParentBottom="true" является ключевым параметром.

Счастливое кодирование.

1

попробуйте использовать RelativeLayout вместо того, чтобы заполнить весь экран и

android:layout_alignParentBottom атрибут

Смежные вопросы