I Implemented a ExpandableListView. But its Items are very long and it doesn't appear in the screen!
I used HorizantalScrollView to solve this problem. But it resized to minimal with(header with).
<?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" >
<HorizontalScrollView
android:id="#+id/horizontalScrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ExpandableListView
android:id="#+id/lstUploadList"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ExpandableListView>
</LinearLayout>
</HorizontalScrollView>
How can I fix this ?
You donot need horizontal scroll view for that what you need is to set the layout_height="wrap_content" .
<?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="wrap_content"
android:orientation="vertical" >
<ExpandableListView
android:id="#+id/lstUploadList"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</ExpandableListView>
</LinearLayout>
or if you want to scroll the layout horizontally than you have to set the width of horizontal layout to wrap_content
<?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" >
<HorizontalScrollView
android:id="#+id/horizontalScrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ExpandableListView
android:id="#+id/lstUploadList"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</ExpandableListView>
</LinearLayout>
</HorizontalScrollView>
Related
Hello guys how can I get a view like this link, it has to be scrollable from vertical and horizontal, I started doing it with recyclerview and it works horizontally but how can I make it to work vertically.
Link of the view to acomplish
https://i.stack.imgur.com/puxEi.png
This is the code for the layouts am using fragments and replacing those on the framelayouts because the test requires me to do so.
--activity main 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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity"
android:background="#color/colorBlack">
<FrameLayout
android:id="#+id/section1"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
</FrameLayout>
<FrameLayout
android:orientation="vertical"
android:id="#+id/section2"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
</FrameLayout>
</LinearLayout>
----section1 and section2 code are the same
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context="fragments.SectionOne"
android:background="#f2f2f2">
<androidx.recyclerview.widget.RecyclerView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="#+id/recyclerView"
android:orientation="horizontal">
</androidx.recyclerview.widget.RecyclerView>
</LinearLayout>
If use scrollview and wrap all this under a single framelayout both sections are overlapping each other
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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:orientation="vertical"
tools:context=".MainActivity"
android:background="#color/colorBlack">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<FrameLayout
android:id="#+id/section1"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
</FrameLayout>
<FrameLayout
android:orientation="vertical"
android:id="#+id/section2"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
</FrameLayout>
</FrameLayout>
</ScrollView>
I have this LinearLayout containing a ListView and a LinearLayout:
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView
android:id="#+id/list_view"
android:layout_width="match_parent"
android:layout_height="fill_parent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<EditText
android:layout_width="fill_parent"
android:layout_height="40dp"
android:hint="Hej"/>
</LinearLayout>
</LinearLayout>
The ListView takes up the entire layout and the LinearLayout with EditText gets added below the bottom edge of the screen and isn't visible. How can I fix this? I tried with layout_weight but didn't work.
That is because you are using fill_parent, and it will do exactly that.
You could try something along the lines of this... It will cause the ListView to expand to fill the space.
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView
android:id="#+id/list_view"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<EditText
android:layout_width="match_parent"
android:layout_height="40dp"
android:hint="Hej"/>
</LinearLayout>
</LinearLayout>
Another alternative is to use a RelativeLayout. So long as the height of the ListView is not wrap_content, it should be OK.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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:orientation="vertical">
<ListView
android:id="#+id/list_view"
android:layout_width="match_parent"
android:layout_above="#+id/footer"
android:layout_height="match_parent"/>
<LinearLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:padding="10dp">
<EditText
android:layout_width="match_parent"
android:layout_height="40dp"
android:hint="Hej"/>
</LinearLayout>
</RelativeLayout>
I'd like to divide my layout screen into two parts:
Half with a ScrollView
Half with a ListView
Is it possible?
Thanks :)
Horizontally :
<?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="horizontal"
android:weightSum="2" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#192832" >
</ScrollView>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#193222" >
</ListView>
</LinearLayout>
Vertically :
<?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="2" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#192832" >
</ScrollView>
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#193222" >
</ListView>
</LinearLayout>
What happens is when I populate my list view the linear layout below the ExpandableListView will disappear. I want the "#+id/bottomActionBarAppointments" layout to be visible always on the screen. I do not want to set a static height to the ExpandableListView.
Thanks in advance for any help.Following is my layout xml:
<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:orientation="vertical"
tools:context=".AppointmentsActivity" >
<LinearLayout
android:id="#+id/calendar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
<ExpandableListView
android:id="#+id/expandableListViewAppointments"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:groupIndicator="#null" >
</ExpandableListView>
<LinearLayout
android:id="#+id/bottomActionBarAppointments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
</LinearLayout>
</LinearLayout>
Found the answer after trying few changes.
I used layout_weight property to allow each linear layout to share a specific portion of the screen.
Following is my layout XML:
<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:orientation="vertical"
tools:context=".AppointmentsActivity" >
<LinearLayout
android:id="#+id/calendar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#color/green"
android:layout_weight="0.1" >
</LinearLayout>
<LinearLayout
android:id="#+id/listViewLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.8">
<ExpandableListView
android:id="#+id/expandableListViewAppointments"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:groupIndicator="#null" >
</ExpandableListView>
</LinearLayout>
<LinearLayout
android:id="#+id/bottomActionBarAppointments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#color/green"
android:layout_weight="0.1">
</LinearLayout>
</LinearLayout>
when i tap the handler the slidingdrawer is brought up but its contents are transparent i can see both the content and the listview.the listview is not hidden.
here is my layout xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="#+id/lvq"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
<SlidingDrawer
android:id="#+id/slidingDrawer1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignBottom="#+id/lvq"
android:layout_alignTop="#+id/lvq"
android:content="#+id/content"
android:handle="#+id/handle" >
<Button
android:id="#+id/handle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="History" />
<LinearLayout
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
</SlidingDrawer>
</RelativeLayout>
thanks in advance!
Put your SlidingDrawer below your ListView.
android:layout_below="#id/lvq"