Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6132669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:07:50+00:00 2026-05-23T17:07:50+00:00

I am trying to build a ListView Activity with a toolbar at the top.

  • 0

I am trying to build a ListView Activity with a toolbar at the top. The rightmost tool in this toolbar will be a handler to a horizontal SlidingDrawer which will provide a sliding EditText on top of the other tools.
First I tried to achieve this with LinearLayout and FrameLayout but the slider went as much as the space that was available minus the tools total width. Right now I have done what I want and works great with the following layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout android:id="@+id/laytoptoolbarhost"
    android:layout_width="fill_parent"
    android:layout_height="55dip"
    android:background="@drawable/toptoolbar_gradient"
    android:padding="5dip">
    <View android:id="@+id/tool10"
        android:layout_width="32dip"
        android:layout_height="32dip"
        android:paddingRight="3dip"
        android:background="#00FF00"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true">
    </View>     
    <View android:id="@+id/tool20"
        android:layout_width="32dip"
        android:layout_height="32dip"
        android:paddingRight="3dip"
        android:background="#00FF00"
        android:layout_toRightOf="@+id/tool10"
        android:layout_centerVertical="true">
    </View>
    <View android:id="@+id/tool30"
        android:layout_width="32dip"
        android:layout_height="32dip"
        android:paddingRight="3dip"
        android:background="#00FF00"
        android:layout_toRightOf="@+id/tool20"
        android:layout_centerVertical="true">
    </View>             
    <SlidingDrawer android:id="@+id/slidesearch"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:handle="@+id/sliderhandle"
        android:content="@+id/txtsearch">
        <ImageView android:id="@+id/sliderhandle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/btn_collapse_states">
        </ImageView>
        <EditText android:id="@+id/txtsearch"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="20sp">
        </EditText>
    </SlidingDrawer>
</RelativeLayout>
<ListView android:id="@id/android:list"
           android:layout_width="match_parent"
           android:layout_height="match_parent"
           android:layout_weight="1"
           android:drawSelectorOnTop="false"/>
 <TextView android:id="@id/android:empty"
           android:layout_width="match_parent"
           android:layout_height="match_parent"
           android:gravity="center"
           android:textSize="20sp"
           android:text="@string/lbl_norecords"/>    

The problem is that I have to put a fixed value in RelativeLayout android:layout_height parameter in order for this to work. If I place “wrap_content” then the RelativeLayout fills the entire screen and nothing else is showing.

Any help on this is highly appreciated

Thank you in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:07:51+00:00Added an answer on May 23, 2026 at 5:07 pm

    Remove android:layout_centerVertical="true" from the views in your Relative Layout. I also made some changes to your slider to get to what you want. The crucial changes to the slider were:

    1. Add: android:layout_alignTop="@+id/tool30" and android:layout_alignBottom="@+id/tool30"

    2. Remove android:layout_alignParentRight="true" and
      android:layout_centerVertical="true"

    I made a few other cosmetic changes elsewhere while debugging the layout.

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <RelativeLayout
            android:id="@+id/laytoptoolbarhost"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="5dip"
            android:layout_weight="0">
            <View
                android:id="@+id/tool10"
                android:layout_width="32dip"
                android:layout_height="32dip"
                android:paddingRight="3dip"
                android:background="#00FF00"
                android:layout_alignParentLeft="true"
                >
            </View>
            <View
                android:id="@+id/tool20"
                android:layout_width="32dip"
                android:layout_height="32dip"
                android:paddingRight="3dip"
                android:background="#FFFF00"
                android:layout_toRightOf="@+id/tool10"
                >
            </View>
            <View
                android:id="@+id/tool30"
                android:layout_width="32dip"
                android:layout_height="32dip"
                android:paddingRight="3dip"
                android:background="#00FFFF"
                android:layout_toRightOf="@+id/tool20"
                >
            </View>
            <SlidingDrawer
                android:id="@+id/slidesearch"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="horizontal"
                android:layout_alignTop="@+id/tool30"
                android:layout_alignBottom="@+id/tool30"
                android:handle="@+id/sliderhandle"
                android:content="@+id/txtsearch">
                <ImageView
                    android:id="@+id/sliderhandle"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/alarm_clock">
                </ImageView>
                <EditText
                    android:id="@+id/txtsearch"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:textSize="20sp">
                </EditText>
            </SlidingDrawer>
        </RelativeLayout>
        <ListView
            android:id="@id/android:list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:drawSelectorOnTop="false" />
        <TextView
            android:id="@id/android:empty"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:textSize="20sp"
            android:text="nothing" 
            />
    </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build an Activity that will serve as a Calendar Day View.
Im trying to built this app which simple consist of a ListView and different
I'm trying build a method which returns the shortest path from one node to
I am trying to build an Android View, with a listview as a header
What I am trying to do is build a layout which if an AdMob
I'm trying to build a Listview EDIT/Insert template where I can use a checkbox
I'm trying to code this ListView and I have no idea on how to
I'm trying to implement a list using the ListView, which contains rows built with
I'm brand new to this and I'm trying build a simple layout of divs.
I'm trying to add strings into a ListView , which gets called inside another

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.