Android: Overlap in ExpandableListview in LinearLeyout - android

In my android application i have an expandable list view and a button in a linearLayout but when i open a sublist, some kind of overlap between items and just listview is in layout and button hidde under listview. I have 2 item over each other. one of them is hiding under other.
How can i fix it?
<?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">
<ExpandableListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/expandableListView"/>
<Button
android:id="#+id/backup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="BackUp"
android:clickable="true"/>
</LinearLayout>

Related

Load more data on Scroll View ends

i want to load more data in a fragment when scroll View reaches end..
My layout has Scroll view with a Linear Layout i am creating Tex view and button dynamically..
<?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"
android:layout_centerInParent="true"
android:background="#drawable/background">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/txtv"
android:textColor="#ffffff"
android:gravity="center"
android:background="#drawable/booktitle" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/scrollViewid"
android:layout_below="#+id/txtv">
<LinearLayout
android:id="#+id/linearlayoutid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:orientation="vertical">
</LinearLayout>
</ScrollView>
</RelativeLayout>
you need to use either a recyclerview or listview for that, scrollview is not meant for that refer this tutorial http://developer.android.com/training/material/lists-cards.html and run this sample app to understand it better http://developer.android.com/samples/RecyclerView/index.html since recyclerview is new i recommend you use that

Cause Layout get focus before its views

I am developing an application for Android TV.
I have a layout which have horizontal LinearLayout (custom) which is used for navigation and below it a container for fragments.
What I want is when a user is focused on any item in the fragment (assuming that the fragment has only 1 row of views), when he clicks on UP on the D-Pad, the LinearLayout above it will get the focus and not the closest.
<?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:gravity="center_horizontal"
android:orientation="vertical">
<com.myApp.tv.view.categories.CategoriesLayout
android:id="#+id/home_categoriesLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="50dp"
android:layout_marginTop="30dp"
android:descendantFocusability="beforeDescendants"
android:focusable="true"
android:orientation="horizontal" />
<FrameLayout
android:id="#+id/home_contentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
I really prefer not to interfere the fragment code.
Please give me your suggestions, thank you

Changing view order in the program

My main.xml has ListView and ImageView. Now ListView is behind the ImageView. How can I make when the user touch the screen, the ImageView is put behind the ListView. How can I implement in the program? My main.xml is as follow.
<?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"
>
<LinearLayout android:id="#+id/tracker_container"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:orientation="vertical"
/>
<ImageView
android:id="#+id/imageView1"
android:contentDescription="#string/display"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/im1"
/>
</LinearLayout>
You can try bring the list view to the top by using
listView.bringToFront()

ExpandableListView groupIndicator is disabled with CheckBox

I am trying to use an ExpandableListView and in the group view I need a textview and a checkbox (checkbox is on the right).
The issue I am seeing is that the groupIndicator view is no longer tappable - tapping on it does not expand the group anymore. If I remove the checkbox, then groupIndicator receives events and group is expandable. The same happens with another View that receives some kind of focus, for example an EditText.
Here is the layout of the fragment containing the ExpandableListView:
<?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" >
<ExpandableListView
android:id="#+id/categoryList"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ExpandableListView>
</RelativeLayout>
The layout of the group:
<?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:background="#color/white_background"
android:orientation="horizontal" >
<TextView
android:id="#+id/txtCategoryGroup"
android:layout_width="0dip"
android:layout_height="#dimen/items_filter_group_height"
android:layout_marginLeft="45dp"
android:layout_marginRight="20dp"
android:layout_weight="1"
android:gravity="center_vertical|left"
android:textIsSelectable="false" />
<!--
<CheckBox
android:id="#+id/cbGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</CheckBox>
-->
</LinearLayout>
... and, if you find useful, the layout of the child:
<?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="#dimen/items_filter_child_height"
android:background="#color/white_background"
android:orientation="horizontal" >
<CheckBox
android:id="#+id/cbProperty"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</CheckBox>
</LinearLayout>
Attached is the layout I am getting if the CheckBox is un-commented:
Tapping on the red-marked groupIndicator doesn't expand the group. Leaving it commented expands it. As said above: what is strange is that the same happens with an EditText.
The work-around is to set the groupIndicator to #null and set the TextView's compound left drawable to something relevant in response to ExpandableListView#OnGroupCollapseListener and #OnGroupExpandListener, but I am not that happy writing code for something like that.
Thanks!
Put android:descendantFocusability="blocksDescendants" in both LinearLayout of the group and child.

Making ListView scrolled with other items

http://realdevs.tistory.com/entry/asdf
↑ Picture.
I have a problem when I use ListView.
As the screen is full of widgets, I would like the ListView's items to be scrolled with other items in the layout.
On the picture, the blue one is a widget on the layout, and the red ones are the items of ListView.
When I scroll up the items, they move, but the blue one doesn't.
How can I make it to move together with ListView as it is an item in ListView?
you an add your blue layout as your listView header.
this will help you in adding a layout as header.
Simply add that blue part in scrollview
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
your layout
........
</ScrollView>
From your pic in http://realdevs.tistory.com/entry/asdf
I'm implement in coding xml this.
<?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="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#e0e0e0"
android:orientation="vertical" >
<!-- this layout add your other items. I'm exam add Button -->
<Button
android:id="#+id/butonTop"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:text="Top Button" />
</LinearLayout>
<!-- ListView in bottom screen and can auto scroll. -->
<ListView
android:id="#+id/dataListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:drawSelectorOnTop="false" >
</ListView>
</LinearLayout>

Categories

Resources