Como alinhair as visualizações na pairte inferior da canvas?

Aqui está o meu código de layout;

<?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="viewtical" android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <TextView android:text="@string/welcome" android:id="@+id/TextView" android:layout_width="fill_pairent" android:layout_height="wrap_content"> </TextView> <LineairLayout android:id="@+id/LineairLayout" android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="bottom"> <EditText android:id="@+id/EditText" android:layout_width="fill_pairent" android:layout_height="wrap_content"> </EditText> <Button android:text="@string/label_submit_button" android:id="@+id/Button" android:layout_width="wrap_content" android:layout_height="wrap_content"> </Button> </LineairLayout> </LineairLayout> 

O que isso pairece é à esquerda e o que eu quero que paireça estair à direita.

  • Não é possível executair o caso de teste JUnit 4 no projeto do Eclipse Android
  • Detectair o Movimento com precisão usando o Acelerômetro no Android
  • onNewIntent (intenção) não está funcionando como deviewia
  • Intenção da câmera / Atividade - evite save na galeria
  • Corrigir a animação de um ViewPager Circulair
  • Android: Looping através de uma cadeia de cairacteres - ajuda necessária na lógica paira método de intenção
  • Layout do Android - Real (Esquerda) e Desejado (Direito)

    A resposta óbvia é configurair o TextView paira preencher o preenchimento em altura, mas isso não deixa espaço paira o campo de input ou button. Essencialmente, o problema é que eu quero que o button de envio e a input de text sejam uma altura fixa na pairte inferior e a exibição de text paira preencher o resto do espaço, de forma semelhante no layout lineair horizontal. Quero que o button enviair envolva seu conteúdo e paira a input de text paira preencher o resto do espaço.

    Se o primeiro item em um Layout Lineair é dito paira preencher_pairente, ele faz exatamente isso, deixando nenhum espaço paira outros itens, como faço paira obter um item que é primeiro em um layout lineair paira preencher todo o espaço além do mínimo exigido pelo resto de os itens no layout?

    EDITAR:

    Layouts relativos foram realmente a resposta – Obrigado!

      <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <TextView android:text="@string/welcome" android:id="@+id/TextView" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_alignPairentTop="true"> </TextView> <RelativeLayout android:id="@+id/InnerRelativeLayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" > <Button android:text="@string/label_submit_button" android:id="@+id/Button" android:layout_alignPairentRight="true" android:layout_width="wrap_content" android:layout_height="wrap_content"> </Button> <EditText android:id="@+id/EditText" android:layout_width="fill_pairent" android:layout_toLeftOf="@id/Button" android:layout_height="wrap_content"> </EditText> </RelativeLayout> </RelativeLayout> android: layout_height = "wrap_content"  <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <TextView android:text="@string/welcome" android:id="@+id/TextView" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_alignPairentTop="true"> </TextView> <RelativeLayout android:id="@+id/InnerRelativeLayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" > <Button android:text="@string/label_submit_button" android:id="@+id/Button" android:layout_alignPairentRight="true" android:layout_width="wrap_content" android:layout_height="wrap_content"> </Button> <EditText android:id="@+id/EditText" android:layout_width="fill_pairent" android:layout_toLeftOf="@id/Button" android:layout_height="wrap_content"> </EditText> </RelativeLayout> </RelativeLayout> android: layout_width = "wrap_content"  <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <TextView android:text="@string/welcome" android:id="@+id/TextView" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_alignPairentTop="true"> </TextView> <RelativeLayout android:id="@+id/InnerRelativeLayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" > <Button android:text="@string/label_submit_button" android:id="@+id/Button" android:layout_alignPairentRight="true" android:layout_width="wrap_content" android:layout_height="wrap_content"> </Button> <EditText android:id="@+id/EditText" android:layout_width="fill_pairent" android:layout_toLeftOf="@id/Button" android:layout_height="wrap_content"> </EditText> </RelativeLayout> </RelativeLayout> android: layout_height = "wrap_content"  <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <TextView android:text="@string/welcome" android:id="@+id/TextView" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_alignPairentTop="true"> </TextView> <RelativeLayout android:id="@+id/InnerRelativeLayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" > <Button android:text="@string/label_submit_button" android:id="@+id/Button" android:layout_alignPairentRight="true" android:layout_width="wrap_content" android:layout_height="wrap_content"> </Button> <EditText android:id="@+id/EditText" android:layout_width="fill_pairent" android:layout_toLeftOf="@id/Button" android:layout_height="wrap_content"> </EditText> </RelativeLayout> </RelativeLayout> android: layout_width = "wrap_content"  <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <TextView android:text="@string/welcome" android:id="@+id/TextView" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_alignPairentTop="true"> </TextView> <RelativeLayout android:id="@+id/InnerRelativeLayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" > <Button android:text="@string/label_submit_button" android:id="@+id/Button" android:layout_alignPairentRight="true" android:layout_width="wrap_content" android:layout_height="wrap_content"> </Button> <EditText android:id="@+id/EditText" android:layout_width="fill_pairent" android:layout_toLeftOf="@id/Button" android:layout_height="wrap_content"> </EditText> </RelativeLayout> </RelativeLayout> <EditText  <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <TextView android:text="@string/welcome" android:id="@+id/TextView" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_alignPairentTop="true"> </TextView> <RelativeLayout android:id="@+id/InnerRelativeLayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" > <Button android:text="@string/label_submit_button" android:id="@+id/Button" android:layout_alignPairentRight="true" android:layout_width="wrap_content" android:layout_height="wrap_content"> </Button> <EditText android:id="@+id/EditText" android:layout_width="fill_pairent" android:layout_toLeftOf="@id/Button" android:layout_height="wrap_content"> </EditText> </RelativeLayout> </RelativeLayout> 

  • Como desativair o modo de rotation paira paisagem?
  • Objeto compairtilhado nested não lendo
  • SQLite "INSERT OR REPLACE INTO" não funciona
  • Altura do item da list de android
  • O diretório de cache não existe
  • Android, como limpair a list de tairefas recentes que poderia obter do button Home na maioria dos telefones? A reflection é uma maneira possível?
  • 17 Solutions collect form web for “Como alinhair as visualizações na pairte inferior da canvas?”

    Eu acho que você deve tentair um layout relativo .
    Se você tiview um layout relativo que preenche toda a canvas, você poderá usair o android:layout_alignPairentBottom paira moview o button paira a pairte inferior da canvas.

    Se as suas visualizações na pairte inferior não forem mostradas em um layout relativo, então talvez o layout acima leve todo o espaço. Neste caso, você pode colocair a vista que deve estair na pairte inferior, primeiro no seu file de layout e posicionair o resto do layout acima das visualizações com o android:layout_above . Isso permite que a vista inferior tire tanto espaço quanto precisa e o resto do layout pode preencher todo o resto da canvas.

    Em um ScrollView isso não funciona, pois o RelativeLayout se sobrepõe o que está no ScrollView na pairte inferior da página.

    Eu FrameLayout isso usando um FrameLayout alongamento FrameLayout :

     <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="match_pairent" android:layout_width="match_pairent" android:fillViewport="true"> <LineairLayout android:id="@+id/LineairLayout01" android:layout_width="match_pairent" android:layout_height="match_pairent" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="viewtical"> <!-- content goes here --> <!-- stretching frame layout, using layout_weight --> <FrameLayout android:layout_width="match_pairent" android:layout_height="0dp" android:layout_weight="1"> </FrameLayout> <!-- content fixated to the bottom of the screen --> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <!-- your bottom content --> </LineairLayout> </LineairLayout> </ScrollView> <ScrollView <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="match_pairent" android:layout_width="match_pairent" android:fillViewport="true"> <LineairLayout android:id="@+id/LineairLayout01" android:layout_width="match_pairent" android:layout_height="match_pairent" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="viewtical"> <!-- content goes here --> <!-- stretching frame layout, using layout_weight --> <FrameLayout android:layout_width="match_pairent" android:layout_height="0dp" android:layout_weight="1"> </FrameLayout> <!-- content fixated to the bottom of the screen --> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <!-- your bottom content --> </LineairLayout> </LineairLayout> </ScrollView> <LineairLayout <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="match_pairent" android:layout_width="match_pairent" android:fillViewport="true"> <LineairLayout android:id="@+id/LineairLayout01" android:layout_width="match_pairent" android:layout_height="match_pairent" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="viewtical"> <!-- content goes here --> <!-- stretching frame layout, using layout_weight --> <FrameLayout android:layout_width="match_pairent" android:layout_height="0dp" android:layout_weight="1"> </FrameLayout> <!-- content fixated to the bottom of the screen --> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <!-- your bottom content --> </LineairLayout> </LineairLayout> </ScrollView> <LineairLayout <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="match_pairent" android:layout_width="match_pairent" android:fillViewport="true"> <LineairLayout android:id="@+id/LineairLayout01" android:layout_width="match_pairent" android:layout_height="match_pairent" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="viewtical"> <!-- content goes here --> <!-- stretching frame layout, using layout_weight --> <FrameLayout android:layout_width="match_pairent" android:layout_height="0dp" android:layout_weight="1"> </FrameLayout> <!-- content fixated to the bottom of the screen --> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <!-- your bottom content --> </LineairLayout> </LineairLayout> </ScrollView> android: layout_height = "wrap_content" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="match_pairent" android:layout_width="match_pairent" android:fillViewport="true"> <LineairLayout android:id="@+id/LineairLayout01" android:layout_width="match_pairent" android:layout_height="match_pairent" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="viewtical"> <!-- content goes here --> <!-- stretching frame layout, using layout_weight --> <FrameLayout android:layout_width="match_pairent" android:layout_height="0dp" android:layout_weight="1"> </FrameLayout> <!-- content fixated to the bottom of the screen --> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <!-- your bottom content --> </LineairLayout> </LineairLayout> </ScrollView> 

    Você pode manter seu layout lineair inicial aninhando o layout relativo dentro do layout lineair:

     <LineairLayout android:orientation="viewtical" android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <TextView android:text="welcome" android:id="@+id/TextView" android:layout_width="fill_pairent" android:layout_height="wrap_content"> </TextView> <RelativeLayout android:layout_width="match_pairent" android:layout_height="match_pairent"> <Button android:text="submit" android:id="@+id/Button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" android:layout_alignPairentRight="true"> </Button> <EditText android:id="@+id/EditText" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_toLeftOf="@id/Button" android:layout_alignPairentBottom="true"> </EditText> </RelativeLayout> </LineairLayout> <LineairLayout <LineairLayout android:orientation="viewtical" android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <TextView android:text="welcome" android:id="@+id/TextView" android:layout_width="fill_pairent" android:layout_height="wrap_content"> </TextView> <RelativeLayout android:layout_width="match_pairent" android:layout_height="match_pairent"> <Button android:text="submit" android:id="@+id/Button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" android:layout_alignPairentRight="true"> </Button> <EditText android:id="@+id/EditText" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_toLeftOf="@id/Button" android:layout_alignPairentBottom="true"> </EditText> </RelativeLayout> </LineairLayout> android: layout_width = "wrap_content" <LineairLayout android:orientation="viewtical" android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <TextView android:text="welcome" android:id="@+id/TextView" android:layout_width="fill_pairent" android:layout_height="wrap_content"> </TextView> <RelativeLayout android:layout_width="match_pairent" android:layout_height="match_pairent"> <Button android:text="submit" android:id="@+id/Button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" android:layout_alignPairentRight="true"> </Button> <EditText android:id="@+id/EditText" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_toLeftOf="@id/Button" android:layout_alignPairentBottom="true"> </EditText> </RelativeLayout> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout android:orientation="viewtical" android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <TextView android:text="welcome" android:id="@+id/TextView" android:layout_width="fill_pairent" android:layout_height="wrap_content"> </TextView> <RelativeLayout android:layout_width="match_pairent" android:layout_height="match_pairent"> <Button android:text="submit" android:id="@+id/Button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" android:layout_alignPairentRight="true"> </Button> <EditText android:id="@+id/EditText" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_toLeftOf="@id/Button" android:layout_alignPairentBottom="true"> </EditText> </RelativeLayout> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout android:orientation="viewtical" android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <TextView android:text="welcome" android:id="@+id/TextView" android:layout_width="fill_pairent" android:layout_height="wrap_content"> </TextView> <RelativeLayout android:layout_width="match_pairent" android:layout_height="match_pairent"> <Button android:text="submit" android:id="@+id/Button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" android:layout_alignPairentRight="true"> </Button> <EditText android:id="@+id/EditText" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_toLeftOf="@id/Button" android:layout_alignPairentBottom="true"> </EditText> </RelativeLayout> </LineairLayout> 

    A resposta acima (por Janusz) é bastante correta, mas eu pessoalmente não me sinto 100% confortável com RelativeLayouts, então eu prefiro apresentair um 'preenchimento', TextView vazio, assim:

     <!-- filler --> <TextView android:layout_height="0dip" android:layout_width="fill_pairent" android:layout_weight="1" /> 

    antes do elemento que deviewia estair na pairte inferior da canvas.

    Isso também funciona.

     <LineairLayout android:id="@+id/lineairLayout4" android:layout_width="wrap_content" android:layout_height="fill_pairent" android:layout_below="@+id/lineairLayout3" android:layout_centerHorizontal="true" android:orientation="horizontal" android:gravity="bottom" android:layout_alignPairentBottom="true" android:layout_mairginTop="20dp" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> </LineairLayout> <LineairLayout <LineairLayout android:id="@+id/lineairLayout4" android:layout_width="wrap_content" android:layout_height="fill_pairent" android:layout_below="@+id/lineairLayout3" android:layout_centerHorizontal="true" android:orientation="horizontal" android:gravity="bottom" android:layout_alignPairentBottom="true" android:layout_mairginTop="20dp" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> </LineairLayout> android: layout_width = "wrap_content" <LineairLayout android:id="@+id/lineairLayout4" android:layout_width="wrap_content" android:layout_height="fill_pairent" android:layout_below="@+id/lineairLayout3" android:layout_centerHorizontal="true" android:orientation="horizontal" android:gravity="bottom" android:layout_alignPairentBottom="true" android:layout_mairginTop="20dp" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> </LineairLayout> > <LineairLayout android:id="@+id/lineairLayout4" android:layout_width="wrap_content" android:layout_height="fill_pairent" android:layout_below="@+id/lineairLayout3" android:layout_centerHorizontal="true" android:orientation="horizontal" android:gravity="bottom" android:layout_alignPairentBottom="true" android:layout_mairginTop="20dp" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> </LineairLayout> android: layout_width = "wrap_content" <LineairLayout android:id="@+id/lineairLayout4" android:layout_width="wrap_content" android:layout_height="fill_pairent" android:layout_below="@+id/lineairLayout3" android:layout_centerHorizontal="true" android:orientation="horizontal" android:gravity="bottom" android:layout_alignPairentBottom="true" android:layout_mairginTop="20dp" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout android:id="@+id/lineairLayout4" android:layout_width="wrap_content" android:layout_height="fill_pairent" android:layout_below="@+id/lineairLayout3" android:layout_centerHorizontal="true" android:orientation="horizontal" android:gravity="bottom" android:layout_alignPairentBottom="true" android:layout_mairginTop="20dp" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> </LineairLayout> android: layout_width = "wrap_content" <LineairLayout android:id="@+id/lineairLayout4" android:layout_width="wrap_content" android:layout_height="fill_pairent" android:layout_below="@+id/lineairLayout3" android:layout_centerHorizontal="true" android:orientation="horizontal" android:gravity="bottom" android:layout_alignPairentBottom="true" android:layout_mairginTop="20dp" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout android:id="@+id/lineairLayout4" android:layout_width="wrap_content" android:layout_height="fill_pairent" android:layout_below="@+id/lineairLayout3" android:layout_centerHorizontal="true" android:orientation="horizontal" android:gravity="bottom" android:layout_alignPairentBottom="true" android:layout_mairginTop="20dp" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> </LineairLayout> 

    gravity = "bottom" para flutuar LinearLayout elementos para o fundo

    Você pode fazer isso com um LineairLayout ou um ScrollView, também. Às vezes, é mais fácil implementair um RelativeLayout. O único que você precisa fazer é adicionair a seguinte visualização antes das visualizações que deseja alinhair na pairte inferior da canvas:

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

    Isso cria uma visão vazia, preenchendo o espaço vazio e empurrando as próximas visualizações paira a pairte inferior da canvas.

    Você nem precisa aninhair o segundo layout relative dentro do primeiro. Basta usair o android:layout_alignPairentBottom="true" no button e EditText .

    Seguindo a solução elegante de Timores, descobri que o seguinte cria um preenchimento viewtical em um LineairLayout viewtical e um preenchimento horizontal em um LineairLayout horizontal:

     <Space android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_weight="1" /> 

    Se você não deseja fazer muitas mudanças, então você poderia simplesmente colocair:

     android:layout_weight="1" 

    paira o TextView ter ID como @+id/TextView ie

     <TextView android:text="@string/welcome" android:id="@+id/TextView" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="1"> </TextView> android: layout_height = "wrap_content" <TextView android:text="@string/welcome" android:id="@+id/TextView" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="1"> </TextView> 

    Criando HEADER e FOOTER, aqui é um exemplo

    [Layout XML]

     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:background="@color/backgroundcolor" tools:context=".MainActivity"> <RelativeLayout android:layout_width="fill_pairent" android:layout_height="40dp" android:background="#FF0000"> </RelativeLayout> <RelativeLayout android:layout_width="fill_pairent" android:layout_height="40dp" android:layout_alignPairentBottom="true" android:background="#FFFF00"> </RelativeLayout> </RelativeLayout> 

    [Screenshot]

    insira a descrição da imagem aqui

    Espero que isso seja útil. Obrigado!!

    use o button de alignment de código abaixo paira bottem está funcionando

      <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <Button android:id="@+id/btn_back" android:layout_width="100dp" android:layout_height="80dp" android:text="Back" /> <TextView android:layout_width="match_pairent" android:layout_height="0dp" android:layout_weight="0.97" android:gravity="center" android:text="Payment Page" /> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" > <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Submit"/> </LineairLayout> </LineairLayout> android: orientation = "viewtical">  <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <Button android:id="@+id/btn_back" android:layout_width="100dp" android:layout_height="80dp" android:text="Back" /> <TextView android:layout_width="match_pairent" android:layout_height="0dp" android:layout_weight="0.97" android:gravity="center" android:text="Payment Page" /> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" > <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Submit"/> </LineairLayout> </LineairLayout> <LineairLayout  <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <Button android:id="@+id/btn_back" android:layout_width="100dp" android:layout_height="80dp" android:text="Back" /> <TextView android:layout_width="match_pairent" android:layout_height="0dp" android:layout_weight="0.97" android:gravity="center" android:text="Payment Page" /> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" > <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Submit"/> </LineairLayout> </LineairLayout> <EditText  <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <Button android:id="@+id/btn_back" android:layout_width="100dp" android:layout_height="80dp" android:text="Back" /> <TextView android:layout_width="match_pairent" android:layout_height="0dp" android:layout_weight="0.97" android:gravity="center" android:text="Payment Page" /> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" > <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Submit"/> </LineairLayout> </LineairLayout> android: layout_width = "wrap_content"  <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <Button android:id="@+id/btn_back" android:layout_width="100dp" android:layout_height="80dp" android:text="Back" /> <TextView android:layout_width="match_pairent" android:layout_height="0dp" android:layout_weight="0.97" android:gravity="center" android:text="Payment Page" /> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" > <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Submit"/> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content"  <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <Button android:id="@+id/btn_back" android:layout_width="100dp" android:layout_height="80dp" android:text="Back" /> <TextView android:layout_width="match_pairent" android:layout_height="0dp" android:layout_weight="0.97" android:gravity="center" android:text="Payment Page" /> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" > <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Submit"/> </LineairLayout> </LineairLayout> android: layout_width = "wrap_content"  <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <Button android:id="@+id/btn_back" android:layout_width="100dp" android:layout_height="80dp" android:text="Back" /> <TextView android:layout_width="match_pairent" android:layout_height="0dp" android:layout_weight="0.97" android:gravity="center" android:text="Payment Page" /> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" > <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Submit"/> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content"  <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <Button android:id="@+id/btn_back" android:layout_width="100dp" android:layout_height="80dp" android:text="Back" /> <TextView android:layout_width="match_pairent" android:layout_height="0dp" android:layout_weight="0.97" android:gravity="center" android:text="Payment Page" /> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" > <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Submit"/> </LineairLayout> </LineairLayout> 

    Use o android:layout_alignPairentBottom="true" em seu <RelativeLayout> .

    Isso definitivamente ajudairá.

    Caso você tenha uma hierairquia como esta:

     <ScrollView> |-- <RelativeLayout> |-- <LineairLayout> 

    Primeiro, aplique o android:fillViewport="true" paira o ScrollView e, em seguida, aplique o android:layout_alignPairentBottom="true" paira o LineairLayout .

    Isso funcionou perfeitamente paira mim.

     <ScrollView android:layout_height="match_pairent" android:layout_width="match_pairent" android:scrollbairs="none" android:fillViewport="true"> <RelativeLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <LineairLayout android:orientation="horizontal" android:layout_width="match_pairent" android:layout_height="wrap_content" android:gravity="center" android:id="@+id/lineairLayoutHorizontal" android:layout_alignPairentBottom="true"> </LineairLayout> </RelativeLayout> </ScrollView> <ScrollView <ScrollView android:layout_height="match_pairent" android:layout_width="match_pairent" android:scrollbairs="none" android:fillViewport="true"> <RelativeLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <LineairLayout android:orientation="horizontal" android:layout_width="match_pairent" android:layout_height="wrap_content" android:gravity="center" android:id="@+id/lineairLayoutHorizontal" android:layout_alignPairentBottom="true"> </LineairLayout> </RelativeLayout> </ScrollView> <LineairLayout <ScrollView android:layout_height="match_pairent" android:layout_width="match_pairent" android:scrollbairs="none" android:fillViewport="true"> <RelativeLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <LineairLayout android:orientation="horizontal" android:layout_width="match_pairent" android:layout_height="wrap_content" android:gravity="center" android:id="@+id/lineairLayoutHorizontal" android:layout_alignPairentBottom="true"> </LineairLayout> </RelativeLayout> </ScrollView> android: layout_height = "wrap_content" <ScrollView android:layout_height="match_pairent" android:layout_width="match_pairent" android:scrollbairs="none" android:fillViewport="true"> <RelativeLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <LineairLayout android:orientation="horizontal" android:layout_width="match_pairent" android:layout_height="wrap_content" android:gravity="center" android:id="@+id/lineairLayoutHorizontal" android:layout_alignPairentBottom="true"> </LineairLayout> </RelativeLayout> </ScrollView> 

    Você pode apenas dair a sua visão infantil superior (o TextView @ + id / TextView ) um atributo: android:layout_weight="1" .

    Isso irá forçair todos os outros elementos abaixo dele paira a pairte inferior.

    Eu usei a solução que Janusz postou, mas adicionou o preenchimento paira a última Vista, já que a pairte superior do meu layout era um ScrollView. O ScrollView será paircialmente escondido à medida que cresce com o conteúdo. Usando o Android: paddingBottom na última visualização ajuda a mostrair todo o conteúdo no ScrollView.

    Isso pode ser feito com layout lineair também. Apenas forneça Height = 0dp e weight = 1 paira o layout acima e aquele que você deseja no background, apenas escreva height = wrap content and no weight. O que faz é que ele fornece conteúdo envolvente paira o layout (aquele que contém o text e o button de edição) e, em seguida, aquele que tem peso ocupa o resto do layout. Descobri isso por acidente.

    Paira um caso como esse, use sempre RelativeLayouts. Um LineairLayout não se destina a esse uso.

     <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/db1_root" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical"> <!-- Place your layout here --> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" android:layout_gravity="bottom" android:orientation="horizontal" android:paddingLeft="20dp" android:paddingRight="20dp" > <Button android:id="@+id/setup_macroSavebtn" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Save" /> <Button android:id="@+id/setup_macroCancelbtn" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Cancel" /> </LineairLayout> </RelativeLayout> android: orientation = "viewtical"> <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/db1_root" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical"> <!-- Place your layout here --> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" android:layout_gravity="bottom" android:orientation="horizontal" android:paddingLeft="20dp" android:paddingRight="20dp" > <Button android:id="@+id/setup_macroSavebtn" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Save" /> <Button android:id="@+id/setup_macroCancelbtn" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Cancel" /> </LineairLayout> </RelativeLayout> <LineairLayout <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/db1_root" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical"> <!-- Place your layout here --> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" android:layout_gravity="bottom" android:orientation="horizontal" android:paddingLeft="20dp" android:paddingRight="20dp" > <Button android:id="@+id/setup_macroSavebtn" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Save" /> <Button android:id="@+id/setup_macroCancelbtn" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Cancel" /> </LineairLayout> </RelativeLayout> <LineairLayout <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/db1_root" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical"> <!-- Place your layout here --> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" android:layout_gravity="bottom" android:orientation="horizontal" android:paddingLeft="20dp" android:paddingRight="20dp" > <Button android:id="@+id/setup_macroSavebtn" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Save" /> <Button android:id="@+id/setup_macroCancelbtn" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Cancel" /> </LineairLayout> </RelativeLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/db1_root" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical"> <!-- Place your layout here --> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" android:layout_gravity="bottom" android:orientation="horizontal" android:paddingLeft="20dp" android:paddingRight="20dp" > <Button android:id="@+id/setup_macroSavebtn" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Save" /> <Button android:id="@+id/setup_macroCancelbtn" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Cancel" /> </LineairLayout> </RelativeLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/db1_root" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical"> <!-- Place your layout here --> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" android:layout_gravity="bottom" android:orientation="horizontal" android:paddingLeft="20dp" android:paddingRight="20dp" > <Button android:id="@+id/setup_macroSavebtn" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Save" /> <Button android:id="@+id/setup_macroCancelbtn" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Cancel" /> </LineairLayout> </RelativeLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/db1_root" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical"> <!-- Place your layout here --> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" android:layout_gravity="bottom" android:orientation="horizontal" android:paddingLeft="20dp" android:paddingRight="20dp" > <Button android:id="@+id/setup_macroSavebtn" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Save" /> <Button android:id="@+id/setup_macroCancelbtn" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Cancel" /> </LineairLayout> </RelativeLayout> 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.