I'm trying to align a listview in middle of 2 views, I tried the following:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#color/white">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No data"
android:id="#+id/empty_state"
android:layout_centerHorizontal="true"/>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/fragment_stock_listView"
android:drawSelectorOnTop="true"
android:dividerHeight="1dp"
android:scrollbarStyle="outsideOverlay"
android:layout_above="#+id/add"
android:layout_below="#+id/empty_state">
</ListView>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_alignParentBottom="true"
android:background="#color/white"
android:id="#+id/add">
<LinearLayout android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="horizontal"
android:gravity="center"
android:clickable="true"
android:background="?android:attr/selectableItemBackground">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="#drawable/plus_small_blue"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add"
android:layout_marginLeft="20dp"
android:textSize="20dp"
android:textColor="#color/mm_blue"
android:layout_gravity="center_vertical"/>
</LinearLayout>
<View android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider"/>
</FrameLayout>
</RelativeLayout>
The result in preview is:
But when the list have less items than screen height, the listview dont get alligned below the "no data" textview, the listview down and gets on top of "add", like the following:
DETAIL: When the list have data I set the "no data" textview visibility to GONE.
What am I doing wrong?
Like #CChi suggested i changed the listview height to match_parent, and now it works perfectly.
I think that you need textview for Nodata and ListView in Linerlayout.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#color/white"
android:orientation="vertical" >
need LinearLayout for TextVeiw (Nodata) and ListView
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:id="#+id/empty_state"
android:layout_width="wrap_content"
android:layout_height="130dp"
android:text="No data" />
</LinearLayout>
<ListView
android:id="#+id/fragment_stock_listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/add"
android:layout_below="#+id/empty_state"
android:dividerHeight="1dp"
android:drawSelectorOnTop="true"
android:scrollbarStyle="outsideOverlay" >
</ListView>
</LinearLayout>
<FrameLayout
android:id="#+id/add"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/white" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="#drawable/plus_small_blue" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="20dp"
android:text="Add"
android:textColor="#color/mm_blue"
android:textSize="20dp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider" />
</FrameLayout>
</RelativeLayout>
Related
i am creating a custom dropdown,where custom dropdown is created using relative layout and listview, on click of relative layout i am making listview to visible and gone, so like this there are many dropdowns vertically one after the other. Without putting scrollview it works fine, Here the problem is if i apply scrollview to whole layout dropdown(which is made using listview) will take only some space and inside the listview itself it enables scroll inside that some space. But i want it to appear as it is without scrolling listview. How could i do this.Any help and suggestion are welcomed.
without scroll view
with scroll view
here i want it to appaer as in without scrollview image ,even if i apply scroll view to whole layout(here whole layout contains number of dropdowns as in figure.)
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:id="#+id/layoutView"
android:background="#drawable/customborder">
<LinearLayout
android:layout_centerVertical="true"
android:id="#+id/Text"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dip">
<TextView
android:id="#+id/viewtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-Select-"
android:textColor="#ff3333"
android:textSize="10dip" />
</LinearLayout>
<ImageView
android:id="#+id/imageView4"
android:layout_width="20dp"
android:layout_height="20dp"
android:padding="0dp"
android:src="#drawable/DropDownArrowIcon"
android:layout_alignParentRight="true" />
</RelativeLayout>
<LinearLayout
android:id="#+id/listViewborder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#2AACFF"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="0.5dp">
<ListView
android:layout_margin="1dp"
android:id="#+id/listView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#57585B"
android:divider="#drawable/list_divider"
android:dividerHeight="1dp" />
</LinearLayout>
<TextView
android:text="Type of bussinness"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/bankInvesttxt"
android:textSize="15dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:id="#+id/layoutView"
android:background="#drawable/customborder">
<LinearLayout
android:layout_centerVertical="true"
android:id="#+id/bankInvestTextlayout"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dip">
<TextView
android:id="#+id/bankInvestviewtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-Select-"
android:textColor="#FFFFFF"
android:textSize="10dip" />
</LinearLayout>
<ImageView
android:id="#+id/bankInvestimageView"
android:layout_width="20dp"
android:layout_height="20dp"
android:padding="0dp"
android:src="#drawable/DropDownArrowIcon"
android:layout_alignParentRight="true" />
</RelativeLayout>
<LinearLayout
android:id="#+id/bankInvestlistViewborder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#2AACFF"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="0.5dp">
<ListView
android:layout_margin="1dp"
android:id="#+id/bankInvestlistView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#57585B"
android:divider="#drawable/list_divider"
android:dividerHeight="1dp" />
</LinearLayout>
</ScrollView>
Try this: layoutView onClick set visiblity as visible the listView and listview itemselected set visiblity as gone. (Do this for both dropdown)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="#+id/layoutView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="8dp" >
<LinearLayout
android:id="#+id/Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="vertical"
android:paddingLeft="10dip" >
<TextView
android:id="#+id/viewtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-Select-"
android:textColor="#ff3333"
android:textSize="10dip" />
</LinearLayout>
<ImageView
android:id="#+id/imageView4"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:padding="0dp" />
</RelativeLayout>
<LinearLayout
android:id="#+id/listViewborder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#2AACFF"
android:gravity="center_horizontal"
android:orientation="vertical"
android:layout_below="#+id/layoutView"
android:visibility="gone"
android:padding="0.5dp" >
<ListView
android:id="#+id/listView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:cacheColorHint="#57585B"
android:dividerHeight="1dp" />
</LinearLayout>
<TextView
android:id="#+id/bankInvesttxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:text="Type of bussinness"
android:layout_below="#+id/layoutView"
android:textSize="15dp" />
<RelativeLayout
android:id="#+id/rel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/bankInvesttxt"
android:padding="8dp" >
<LinearLayout
android:id="#+id/bankInvestTextlayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="vertical"
android:paddingLeft="10dip" >
<TextView
android:id="#+id/bankInvestviewtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-Select-"
android:textColor="#FFFFFF"
android:textSize="10dip" />
</LinearLayout>
<ImageView
android:id="#+id/bankInvestimageView"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:padding="0dp" />
</RelativeLayout>
<LinearLayout
android:id="#+id/bankInvestlistViewborder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#2AACFF"
android:gravity="center_horizontal"
android:orientation="vertical"
android:visibility="gone"
android:layout_below="#+id/rel"
android:padding="0.5dp" >
<ListView
android:id="#+id/bankInvestlistView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:cacheColorHint="#57585B"
android:dividerHeight="1dp" />
</LinearLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:text="Mesaj Başlığı"
android:padding="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textExtendHeader"
android:layout_marginBottom="2dp"
android:textStyle="bold"
android:textSize="22sp" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_x="0dp"
android:layout_y="0dp"
android:layout_gravity="center_horizontal|top">
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="000dp">
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:gravity="top">
<ListView
android:id="#+id/ListC"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#FFDAFF7F"
android:focusable="true"
android:focusableInTouchMode="true"
android:footerDividersEnabled="true"
android:headerDividersEnabled="true"
android:fastScrollEnabled="true"
android:fastScrollAlwaysVisible="true"
android:clickable="true"
android:scrollingCache="true"
android:smoothScrollbar="true"
android:stackFromBottom="false"
android:drawSelectorOnTop="true" />
</ScrollView>
</TableRow>
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="33dp"
android:layout_x="0dp"
android:layout_y="135dp"
android:layout_gravity="center_horizontal|top">
<View
android:layout_marginTop="15dp"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="33dp"
android:layout_x="0dp"
android:layout_y="135dp"
android:layout_gravity="center_horizontal|top">
<View
android:layout_marginTop="15dp"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray" />
</FrameLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:showDividers="middle">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="72dp"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="0px"
android:layout_height="wrap_content"
android:id="#+id/linearLayout12"
android:layout_weight="1"
android:layout_gravity="center">
<TextView
android:text="Çağrı Bilgileri"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textExtendHeader"
android:layout_marginBottom="2dp"
android:textSize="22sp" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="33dp"
android:layout_x="0dp"
android:layout_y="135dp"
android:layout_gravity="center_horizontal|top">
<View
android:layout_marginTop="15dp"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray" />
</FrameLayout>
<TextView
android:text="Mesaj Başlığı"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textExtendHeader"
android:layout_marginBottom="2dp"
android:textSize="22sp" />
<TextView
android:text="mesaj içeriği"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="10dp"
android:id="#+id/textExtendBody" />
<TextView
android:text="Tarih"
android:layout_width="match_parent"
android:paddingTop="10dp"
android:gravity="right"
android:paddingRight="10dp"
android:layout_height="match_parent"
android:id="#+id/textExtendDatetime" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="72dp"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<ImageView
android:src="#android:drawable/ic_menu_gallery"
android:layout_width="40dp"
android:layout_height="40dp"
android:id="#+id/avatarView3"
android:layout_gravity="center"
android:layout_marginRight="16dp" />
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="0px"
android:layout_height="wrap_content"
android:id="#+id/linearLayout15"
android:layout_weight="1"
android:layout_gravity="center">
<TextView
android:text="Effective Navigation in Android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/item_text_primary3"
android:layout_marginBottom="2dp" />
<TextView
android:text="James Montemagno"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/item_text_primary4" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="72dp"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<ImageView
android:src="#android:drawable/ic_menu_gallery"
android:layout_width="40dp"
android:layout_height="40dp"
android:id="#+id/avatarView4"
android:layout_gravity="center"
android:layout_marginRight="16dp" />
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="0px"
android:layout_height="wrap_content"
android:id="#+id/linearLayout16"
android:layout_weight="1"
android:layout_gravity="center">
<TextView
android:text="Mastering Time and Space"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/item_text_primary7"
android:layout_marginBottom="2dp" />
<TextView
android:text="Jérémie Laval"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/item_text_primary8" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
This is my layout full page scrollview, i got a listview on this page too, but when i use scrollview can not move or scroll listview rows, is there any sample? i try to use listview header and footer but i couldnt success any advice?
You should change your layout. You have three Object with scrolling which you set inside each other. Try to avoid ListView inside ScrollView. In this case you have a problem that system can't understand where to catch your touch and scroll after that on screen. Your ListView is a nested element of ScrollView. ListView always sets focus on his parent, that's why it can't scroll.
Do not nest Listview, inside ScrollView. Listview will allow scrolling by default.
And since you nested listview inside the scrollview, listview is not able to get events. Hence, you are not able to scroll.
You've got a ListView in a ScrollView in a ScrollView, pick one!
Your ListView is already scrollable and handles view recycling automatically so that should work fine by itself.
I have a listview in inside a RelativeLayout. The size of my relativelayour change according the size of my listview (number of rows). If it has only two rows, the relative layout stays larger. If it has more rows, the relative stays smaller.
This happen only in small devices.
What do I do?
EDIT: CODE BELOW
<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"
android:background="#drawable/bg_cinza_transparente_98_porcento"
android:orientation="vertical"
tools:context=".AdicionarMarcaModeloActivity" >
<LinearLayout
style="#style/..."
android:layout_width="match_parent"
android:background="#color/cinza_escuro"
android:orientation="vertical" >
<RelativeLayout
style="#style/..."
android:orientation="vertical" >
<TextView
android:id="#+id/labelCabecalhoMarcaModelo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Marca"
android:textColor="#android:color/white"
android:textSize="22sp" />
<ImageView
android:id="#+id/imgCloseMarcaModelo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:src="#drawable/bt_close" />
</RelativeLayout>
<RelativeLayout
style="#style/..."
android:layout_width="match_parent"
android:background="#color/branco_gelo"
android:orientation="vertical" >
<TextView
android:id="#+id/labelSubCabecalhoMarcaModelo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="SELECIONE A MARCA DO SEU VEÍCULO"
android:textColor="#color/cinza_escuro_fontes_cabecalho" />
</RelativeLayout>
</LinearLayout>
<RelativeLayout
style="#style/..."
android:layout_width="match_parent"
android:orientation="horizontal" >
<ListView
android:id="#+id/lvMarcaModelo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#drawable/line" >
</ListView>
</RelativeLayout>
// Try this way,hope this will help you to solve your problem...
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/labelCabecalhoMarcaModelo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Marca"
android:textColor="#android:color/white"
android:layout_gravity="center_horizontal"
android:textSize="22sp" />
<ImageView
android:id="#+id/imgCloseMarcaModelo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:src="#drawable/ic_launcher"
android:layout_marginTop="5dp"/>
<TextView
android:id="#+id/labelSubCabecalhoMarcaModelo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="SELECIONE A MARCA DO SEU VEÍCULO"
android:layout_marginTop="5dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginTop="5dp">
<ListView
android:id="#+id/lvMarcaModelo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#drawable/line" >
</ListView>
</LinearLayout>
</LinearLayout>
So for my landscape layout of a page, I want to have a sort of horizontal layout. However, my FrameLayout including my ListView goes off the screen, even though it's set to android:layout_width="match_parent". Here's a screenshot of what I mean:
The blue line is the outline of where the FrameLayout is going, when it is set to match parent.
Here's my XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/contactlist"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:background="#drawable/brushed_metal_background_dark"
android:orientation="vertical"
tools:context=".ContactList" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#drawable/headerbackground"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:scaleType="center"
android:src="#drawable/homeheader7" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:paddingRight="3sp"
android:text="#string/version"
android:textColor="#FFFFFF"
android:textStyle="italic" >
</TextView>
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#null"
android:onClick="setOptions"
android:src="#drawable/menu" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical" >
<ImageButton
android:id="#+id/report"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#null"
android:gravity="left"
android:onClick="report"
android:scaleType="center"
android:src="#drawable/submit_report" />
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:adjustViewBounds="true"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:scaleType="center"
android:src="#drawable/divider_ver" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical" >
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:scaleType="center"
android:src="#drawable/schoolfeed2" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="100"
android:background="#drawable/background_overlay_dark"
android:duplicateParentState="false"
android:fadingEdge="horizontal"
android:paddingBottom="9dp"
android:paddingLeft="16dp"
android:paddingRight="10dp"
android:paddingTop="7dp" >
<ListView
android:id="#+id/schoolFeed"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:dividerHeight="2dp"
android:footerDividersEnabled="false"
android:headerDividersEnabled="true"
android:scrollbarDefaultDelayBeforeFade="50000"
android:scrollbarStyle="outsideInset"
android:scrollbarThumbVertical="#drawable/scrollbar_vertical_thumb"
android:scrollbarTrackVertical="#drawable/scrollbar_vertical_track" >
</ListView>
</FrameLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Any help is appreciated! Thanks,
I would recommend you that, instead of using match_parent, use wrap_content, becuase, actually, whats happening is that the framelayout has the same width of the screen, so, as it isn't at the left of the screen, it goes off.
I have a layout xml like below:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:maxWidth="71dip"
android:src="#drawable/logo_top" >
</ImageView>
<ImageView
android:id="#+id/imageView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:adjustViewBounds="false"
android:clickable="true"
android:maxHeight="70dip"
android:src="#drawable/registeration_title" >
</ImageView>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" >
</TextView>
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="#+id/linearframe"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<FrameLayout
android:id="#+id/informationFrame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal" >
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:src="#drawable/registeration_info1" />
<TextView
android:id="#+id/IDNumberTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="7dip"
android:layout_marginLeft="26dip"
android:text="TextView"
android:textColor="#drawable/textgreen" />
<TextView
android:id="#+id/EnableDateTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="7dip"
android:layout_marginLeft="140dip"
android:text="TextView"
android:textColor="#drawable/textgreen" />
</FrameLayout>
</LinearLayout>
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/linearframe"
android:text=" " />
<ImageView
android:id="#+id/imageView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textView2"
android:layout_centerHorizontal="true"
android:src="#drawable/buy_in_60" />
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_alignLeft="#id/imageView5"
android:layout_alignRight="#id/imageView5"
android:layout_below="#id/imageView5" >
</ListView>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" " />
<FrameLayout
android:id="#+id/frameLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/listView1"
android:layout_centerHorizontal="true"
android:layout_marginLeft="79dp" >
<ImageView
android:id="#+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/registeration_info2" />
<TextView
android:id="#+id/VersionTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="48dip"
android:text="Version: 1.0"
android:textColor="#drawable/darkgreen" />
</FrameLayout>
<TextView
android:id="#+id/RevisionTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/frameLayout2"
android:layout_centerHorizontal="true"
android:layout_marginLeft="79dp"
android:text="Revision: 16"
android:textColor="#drawable/darkgreen" />
</RelativeLayout>
some layouts below the ListView in the xml will disappear on the screen
and I tried to put the ListView and other layouts below the ListView into a scrollView
but the ListView will shrink, it looks too small, so i remove the ScrollView,
how should i do to let them appear on the screen without ScrollView?
You need to set Weight to your layouts like this way..
like you can set ListView Weight is= 0.80 and Bottom View is = 0.20 make sure parent Linear layout Weight sum is = 1.
You can see this is my xml file having List View (80% screen) and bottom Bar layout for Google Ads (almost 20% screen).
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1">
<LinearLayout
android:id="#+id/layVrt"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_weight="0.72"
android:weightSum="1">
<ListView
android:layout_width="match_parent"
android:id="#+id/listViewGame"
android:textFilterEnabled="true"
android:layout_height="350dp"
android:layout_weight="0.73"></ListView>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:gravity="center"
android:layout_width="match_parent"
android:layout_weight="0.20"
android:layout_marginTop="5dp"
android:background="#drawable/rounded_corners_white"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:layout_height="50dp"
android:layout_marginBottom="3dp"
android:id="#+id/layoutAdMobList">
</LinearLayout>
</LinearLayout>
so this will be the output..
Or you can try something like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottom_bar" >
</ListView>
<LinearLayout
android:id="#+id/bottom_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#drawable/bottom_bar"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ToggleButton
android:id="#+id/slider_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:background="#drawable/bottom_toggle_button" />
<ToggleButton
android:id="#+id/list_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:background="#drawable/bottom_left_button" />
<ToggleButton
android:id="#+id/map_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/bottom_right_button" />
</LinearLayout>
</RelativeLayout>
Place everything inside a RelativeLayout and use android:layout_above="#+id/bottom_bar" on the ListView