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>
Related
I want to create a button which will overlay between 2 layouts.
I am using Linear Layout and added appropriate weight to it.
Have attached a screen shot for reference.
Here is my XML
tag.xml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:weightSum="100" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="30"
android:background="#color/greyColor"
android:gravity="center" >
<ImageView
android:id="#+id/ximgvwCamera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/camera_big" />
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="70"
android:background="#android:color/white" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="#android:color/white"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="5dp"
android:padding="5dp"
android:text="#string/strQ1"
android:textAppearance="#android:style/TextAppearance.Medium"
android:textColor="#android:color/darker_gray" />
</LinearLayout>
</ScrollView>
Please help me in this.
Thanks in advance!
Try this it will working...
<FrameLayout 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="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="150dp" >
<ImageView
android:id="#+id/imageCover"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="#drawable/image_top" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:background="#drawable/image_bottom"
android:layout_height="match_parent" >
</LinearLayout>
</LinearLayout>
<ImageView
android:id="#+id/imageProfile"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="end"
android:layout_marginTop="100dp"
android:src="#drawable/ic_launcher" />
</FrameLayout>
View like this
You need a relative layout. Set image alignt to right-top and set margin top appropriately.
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/first"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:src="#drawable/firstImage" />
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:src="#drawable/middleImage" >
</ImageView>
<RelativeLayout
android:id="#+id/second"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:layout_below="#id/first"
android:src="#drawable/share_over" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="20dp"
android:orientation="horizontal" >
<ImageView
android:id="#+id/YES"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/YES" />
<ImageView
android:id="#+id/NO"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/NO" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
Divide your image TOP-MIDDLE-BOTTOM(layout). Your size looking like above but
you can change width/height size.
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>
I have a ListView that is not scrolling for complete. I inserted 20 items, but the listview is scrolling until the item 15º.
My Layout XML code here :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.6"
android:background="#color/sky" >
<TextView
android:id="#+id/tvQuote"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:gravity="center_vertical|center_horizontal"
android:scrollbars="none"
android:text="#string/QuoteTeste"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/white"
android:textSize="14pt" />
<Space
android:id="#+id/espaco"
android:layout_width="wrap_content"
android:layout_height="30dp" >
</Space>
<TextView
android:id="#+id/tvAutor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/tvQuote"
android:layout_below="#+id/tvQuote"
android:layout_marginTop="22dp"
android:text="(Carlos Drummond)"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/white" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:id="#+id/checklistview"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
</ListView>
</RelativeLayout>
</LinearLayout>
Here a screenshot:
I don't understand WHY this is happening. For example, If I put 6 items, the 6º item is not show and I can't scroll the listview. Missing something?
The problem is in your layout xml
change it with this one:
<?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" >
<RelativeLayout
android:id="#+id/topPart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/sky" >
<TextView
android:id="#+id/tvQuote"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:gravity="center_vertical|center_horizontal"
android:scrollbars="none"
android:text="#string/QuoteTeste"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/white"
android:textSize="14pt" />
<Space
android:id="#+id/espaco"
android:layout_width="wrap_content"
android:layout_height="30dp" >
</Space>
<TextView
android:id="#+id/tvAutor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/tvQuote"
android:layout_below="#+id/tvQuote"
android:layout_marginTop="22dp"
android:text="(Carlos Drummond)"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/white" />
</RelativeLayout>
<ListView
android:id="#+id/checklistview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/topPart" >
</ListView>
</RelativeLayout>
You should not add multiple enties below each other using android:layout_height="fill_parent" or "match_parent" (which is the same) in the same layout as you do in the LinearLayout.
Make it another RelativeLayout with using layout_below, layout_parentOnBottom and other options or place everything into one huge relative layout.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1" >
<RelativeLayout
android:id="#+id/toppart"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/sky" >
<TextView
android:id="#+id/tvQuote"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:gravity="center_vertical|center_horizontal"
android:scrollbars="none"
android:text="#string/QuoteTeste"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/white"
android:textSize="14pt" />
<Space
android:id="#+id/espaco"
android:layout_width="wrap_content"
android:layout_height="30dp" >
</Space>
<TextView
android:id="#+id/tvAutor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/tvQuote"
android:layout_below="#+id/tvQuote"
android:layout_marginTop="22dp"
android:text="(Carlos Drummond)"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/white" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/bottompart"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_below="#+id/toppart"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ListView
android:id="#+id/checklistview"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
</ListView>
</RelativeLayout>
i am working on a layout with 3 buttons and an image view i call the imageview as the first child of the parent however when i build it on actual device the imageview goes down after the buttons... really weird....
heres the xml file:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/background" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_gravity="center"
android:orientation="vertical">
<ImageView
android:id="#+id/title_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/111"
android:visibility="visible" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/222"
android:visibility="visible"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_medium"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/highscores_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/highscore_btn"
android:visibility="visible" />
<Button
android:id="#+id/more_apps_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/margin_medium"
android:background="#drawable/333"
android:visibility="visible" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
is this because of the size of the imageview? it is really large so i put it in xxhdpi folder so it will be reduced. any thoughts? thanks
// try this
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/background" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent">
<ImageView
android:id="#+id/title_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/111"
android:visibility="visible" />
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/222"
android:visibility="visible"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_medium"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/highscores_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/highscore_btn"
android:visibility="visible" />
<Button
android:id="#+id/more_apps_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/margin_medium"
android:background="#drawable/333"
android:visibility="visible" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
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