android - Cant arrange LinearLayout to show button at the bottom with ListView above -


consider next piece of xml -

<linearlayout     xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:orientation="vertical">      <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.android.fiby.fragments.menufragment"              android:orientation="vertical"              android:layout_weight="0.7">          <com.android.fiby.titlefont             android:layout_margintop="5dp"             android:layout_marginbottom="5dp"             android:textcolor="#5e240a"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_gravity="center"             android:textsize="40dp"             android:text="בדיקה"             android:id="@+id/list_title"/>          <listview             android:id="@android:id/list"             android:layout_width="fill_parent"             android:layout_height="fill_parent"/>      </linearlayout>      <linearlayout android:layout_width="fill_parent"               android:layout_height="wrap_content"               android:visibility="visible"               android:layout_gravity="bottom"               android:gravity="center"                   android:layout_weight="0.05">          <imageview             android:id="@+id/buy_now"             android:layout_margintop="5dp"             android:layout_marginbottom="5dp"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:src="@drawable/button"/>      </linearlayout>  </linearlayout> 

and how looks (ignore fab , action button) enter image description here

the problem when erase element list view, button goes well. want that, no matter how many items in listview, button @ bottom.

edit

i've tried using relative layout following way -

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android"                 android:layout_width="fill_parent"                 android:layout_height="fill_parent">      <com.android.fiby.titlefont         android:textcolor="#5e240a"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center"         android:textsize="40dp"         android:text="בדיקה"         android:id="@+id/list_title"         android:layout_alignparenttop="true"          android:layout_centerhorizontal="true"/>        <listview         android:layout_below="@+id/list_title"         android:id="@android:id/list"         android:layout_width="fill_parent"         android:layout_height="fill_parent"/>      <imageview         android:layout_below="@android:id/list"         android:id="@+id/buy_now"         android:layout_margintop="5dp"         android:layout_marginbottom="5dp"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:src="@drawable/button"         android:layout_gravity="center"         android:layout_alignparentbottom="true"/>   </relativelayout> 

but problem listview overrides button -

enter image description here

i dont want chang height of list since other activities, disable image visibility use it.

you can use relativelayout instead linearlayout , set button below listview. this:

<linearlayout android:layout_width="fill_parent"           android:layout_height="wrap_content"           android:visibility="visible"           android:layout_gravity="bottom"           android:gravity="center"           android:id="@+id/listview"           android:layout_weight="0.05">      <imageview         android:id="@+id/buy_now"         android:layout_margintop="5dp"         android:layout_marginbottom="5dp"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_below="@+id/listview"         android:src="@drawable/button"/> 

or if want button in bottom of activity try this:

        android:layout_alignparentbottom="true" 

edit1: try setting listview above button instead of button below listview.

<listview     android:layout_below="@+id/list_title"     android:id="@android:id/list"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:layout_above="@+id/buy_now"/>  <button     android:id="@+id/buy_now"     android:layout_margintop="5dp"     android:layout_marginbottom="5dp"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_gravity="center"     android:layout_alignparentbottom="true"/> 

or can use scrollview...


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -