Layout with listview questions

Asked

Viewed 50 times

1

I’m facing a problem in layout, in this layout I have a Listview and after I have 3 more Buttons only when the list is too big it uses all screen size and I can’t see the Buttons, someone can help me?

How is the layout:

<?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:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">



    <EditText
        android:layout_width="match_parent"
        android:inputType="textPersonName"
        android:ems="10"
        android:id="@+id/edtPesquisa"
        android:drawableLeft="@drawable/ic_lupa"
        android:layout_marginTop="15dp"
        android:hint="Pesquisa rápida"
        tools:ignore="HardcodedText,RtlHardcoded,UnusedAttribute"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:elevation="1dp"
        android:layout_height="40dp" />

    <ListView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/listDebitosPendentes"
        android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
        tools:ignore="NestedScrolling"
        android:footerDividersEnabled="false"/>

    <Button
        android:text="Enviar boleto por e-mail"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/enviaBoletoEmail"
        tools:ignore="HardcodedText" />

    <Button
        android:text="@string/enviar_linha_digit_vel_por_sms"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/enviaLinhaDigitavel" />

    <Button
        android:text="@string/mostrar_linha_digit_vel"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/mostraLinhaDigitável" />


</LinearLayout>

2 answers

2


Add to ListView the weight android:layout_weight="1" this way the layout will reorganize.

  • It worked here, thank you very much.

  • Just one question, could I add this weight by java code?

  • I believe you have as yes, to do a search like this, vc can search more or less like this "layout_weight android programmatically" in google.

0

You need to use a component called Scrollview

<ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <include layout="@layout/minha_tela_"> </include>
    </ScrollView>

You’ll basically have two xmls... one representing the entire layout, and one with this component. In Activity use setContentView in this layout that has scrollview. (Detail: in this layout that has the scrollview will ONLY have it. Everything else will be in the layout I called "my screen")

  • I added it the way you told me, but it got weird my listview, it only shows one item at a time.

  • Actually just set the layout "father" to match_parent...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.