android expandlistview arrow - android

I know how to make an expandedlistview, but I don't know what should i use to see the arrow down and up , how please ?
like when i open a group the arrow becomes down and when i close it , the arrow becomes up
Main xml
<?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="fill_parent"
android:orientation="vertical" >
<ExpandableListView
android:id="#+id/ExpList"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:groupIndicator="#null" />
</LinearLayout>
Group xml
<?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="55dip"
android:background="#FF0000"
android:orientation="vertical" >
<TextView
android:id="#+id/tvGroup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:textColor="#000000"
android:textSize="17dip" />
</LinearLayout>
child 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="55dip"
android:background="#FF0000"
android:orientation="vertical" >
<TextView
android:id="#+id/tvChild"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="17dip" />
</LinearLayout>

remove this line from your xml code android:groupIndicator="#null"

Related

listview items not filled the whole area(Expandable list view)

i am referring this to implement 3 level expandable list. the code works fine. but my problem is , the items in the child elements not filled the whole area. because of that i cant expand the next child element by clicking on it.(i have to click the exact area which is child element text appeared)
can someone point me, where is the issue?
i have edit my xml view also as android:layout_width="fill_parent"
but didn't worked..
please help me on this.
thank you.
EDIT
HERE THE ALL LAYOUT XML CODES.
ROOT
<?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="fill_parent"
android:layout_height="wrap_content"
android:background="#ff5b5b"
android:orientation="vertical" >
<TextView
android:id="#+id/itemRootTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
tools:ignore="HardcodedText" />
</LinearLayout>
PARENT
<?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="fill_parent"
android:layout_height="wrap_content"
android:background="#40e0d0"
android:orientation="vertical" >
<TextView
android:id="#+id/itemParentTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
tools:ignore="HardcodedText" />
</LinearLayout>
CHILD
<?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="fill_parent"
android:layout_height="wrap_content"
android:background="#839096"
android:orientation="vertical" >
<TextView
android:id="#+id/itemChildTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
tools:ignore="HardcodedText" />
</LinearLayout>
MAIN XML LAYOUT
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<ExpandableListView
android:id="#+id/expList"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice"
>
</ExpandableListView>
</RelativeLayout>
I also encountered this problem with a spinner
I solved it like this
child xml.
<?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="fill_parent"
android:layout_height="wrap_content"
android:background="#839096"
android:orientation="vertical" >
<TextView
android:id="#+id/itemChildTitle"
android:layout_width="match_parent" <== and this
android:minWidth="500dp" <=== add this
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
tools:ignore="HardcodedText" />
</LinearLayout>

Displaying a Gridview and ViewPager in the same layout

I would like to display on the same page a viewpager and a gridview like this one ![What I would like :)][1]
[1]: http://i.stack.imgur.com/Xzg7T.jpg but what i get is that ![what I got][1]
[1]: http://i.stack.imgur.com/iZxwU.png .
There are my layouts.The Gridview Item
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="#+id/frag_Acc_gridView_imageView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#215487"
android:scaleType="centerCrop"
android:src="#drawable/ic_logo"/>
<TextView
android:id="#+id/frag_Acc_gridview_textView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/frag_Acc_gridView_imageView"
android:layout_alignParentLeft="true"
android:background="#80000000"
android:gravity="center"
android:paddingLeft="15dp"
android:textColor="#ffffffff"
android:textSize="20sp"
android:text="#string/hello_world" />
</RelativeLayout>
GridView 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" >
<GridView
android:id="#+id/fragment_acc_gridview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:numColumns="auto_fit"
android:stretchMode="columnWidth" >
</GridView>
</LinearLayout>
the main layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="10"
tools:context=".MainActivity">
<FrameLayout
android:id="#+id/fragment_acc_viewpager"
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="6">
</FrameLayout>
<FrameLayout
android:id="#+id/fragment_accueil_gridview"
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="4"
>
</FrameLayout>
</LinearLayout>
thanks
Take a look of this. You will get some help:-
http://www.rogcg.com/blog/2013/10/20/working-with-fragments-and-viewpager-on-android

How can I create and position a container over a Layout?

In Xamarin, how can I create and position a container over a Layout?
Here is my Layout XML code:
<?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">
<FrameLayout
android:id="#+id/mapWithOverlay"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
How can I create a container that has a TextView and a Button and then position this container where I want on top of the FrameLayout?
Thanks in advance
Use Relative Layout, you can arrange the elements where ever you want.
Check here Relative Layout
Here you go:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:padding="5dip" >
<LinearLayout
android:id="#+id/thumbnail"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
<FrameLayout
android:id="#+id/mapWithOverlay"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_below="#+id/thumbnail" />
</RelativeLayout>

relative layout position

I have a vertical linearlayout, it has inside two linearlayout with diferent elements, I would like to fix the first one to the top, and the second one centered, I'm trying it but doesn't work:
<?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"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background_bg"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dip"
android:background="#3b5998"
>
elements
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="300dip"
android:layout_height="300dip"
android:background="#drawable/background_resto"
android:gravity="center"
>
elements
</LinearLayout>
</LinearLayout
Why is it not working? Thank you in advance
I'd advice to choose a RelativeLayout for that purpose.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#android:color/holo_blue_bright"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dip"
android:layout_alignParentTop="true"
android:background="#fff" >
</LinearLayout>
<LinearLayout
android:layout_width="300dip"
android:layout_height="300dip"
android:layout_centerInParent="true"
android:background="#android:color/holo_green_light"
android:orientation="vertical" >
</LinearLayout>
</RelativeLayout>
This will help you to set the exact "relative" position in relation to other views.
Best wishes,
Tim
should use RelativeLayout instead of LinearLayout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background_bg"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dip"
android:background="#3b5998"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
>
elements
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="300dip"
android:layout_height="300dip"
android:background="#drawable/background_resto"
android:layout_centerInParent="true"
>
elements
</LinearLayout>
</RelativeLayout>
<?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="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background_bg"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dip"
android:layout_alignParentTop="true"
android:background="#ff0000" >
</LinearLayout>
<LinearLayout
android:layout_width="300dip"
android:layout_height="300dip"
android:layout_centerInParent="true"
android:background="#ff0000"
android:orientation="vertical" >
</LinearLayout>
</RelativeLayout>
</LinearLayout>

Why LinearLayout looks like this (a white space between elements)?

This is the basic XML file
<?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="fill_parent"
android:orientation="vertical"
android:background="#color/white"
>
<!--top part-->
<include layout="#layout/top" android:layout_width="fill_parent"
android:layout_height="0dp" android:layout_weight="1"/>
<!--content area-->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="5"
android:background="#ff6600"
>
</LinearLayout>
<!--bottom part-->
<include layout="#layout/bottom" android:layout_width="fill_parent"
android:layout_height="0dp" android:layout_weight="1"/>
</LinearLayout>
When I load it in the emulator, it looks like on the image below.
What am I doing wrong?
EDIT
This is top and bottom XML. Basic as well.
<?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="fill_parent"
>
<ImageView
android:id="#+id/bottom_image"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:adjustViewBounds="true"
android:src="#drawable/bottom"
/>
</LinearLayout>
-----------------------------------------------------------
<?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="fill_parent"
>
<ImageView
android:id="#+id/top_image"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:adjustViewBounds="true"
android:src="#drawable/top"
/>
Please try following
Top.xml
<?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:id="#+id/top"
>
<ImageView
android:id="#+id/top_image"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:adjustViewBounds="true"
android:src="#drawable/top"
android:scaleType="fitXY"/>
</LinearLayout>
Bottom.xml
<?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:id="#+id/bottom"
>
<ImageView
android:id="#+id/bottom_image"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:adjustViewBounds="true"
android:src="#drawable/bottom"
android:scaleType="fitXY"/>
</LinearLayout>
and finally Main.xml
<?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="fill_parent"
android:orientation="vertical"
android:background="#000000"
>
<!--top part-->
<include layout="#layout/top" android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<!--content area-->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#ff6600"
>
</LinearLayout>
<!--bottom part-->
<include layout="#layout/bottom" android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
This will solve your problem
remove the android:layout_weight from your top and bottom parts (and set it to anything you want, different than 0, in the content area). This way the content will take all the available space.
On what you did, you only told the content to take 5/7 of the available space, which will behave as you show depending on your screen proportions.
And on a real Smartphone? Is there a space, too?
Have you got the newest Version of the SDK Platform tools?
Check for layout_bottom and layout_top definition. Most probably these layouts have marginTop and marginBottom set.

Categories

Resources