How item of listview adapt the content’s height automatic? - android

When there are many contents in listview, item’s height can full screen or over the screen. The contents is few, in the screen can display many items. How could item of listview adapt the content’s height automatic?
My item layout:
<?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:orientation="horizontal" >
<FrameLayout
android:id="#+id/main_item_frameLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="4dp"
android:layout_marginTop="10dp" >
<ImageView
android:id="#+id/imageHead"
android:layout_width="#dimen/wb_head_image"
android:layout_height="#dimen/wb_head_image" />
<ProgressBar
android:id="#+id/main_item_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="false"
android:indeterminateDrawable="#anim/loading"
android:visibility="gone" />
</FrameLayout>
<LinearLayout
android:id="#+id/main_item_linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="#id/main_item_frameLayout"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical" >
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:paddingLeft="10dp"
android:paddingTop="10dp"
android:textSize="18sp" />
<TextView
android:id="#+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:paddingRight="10dp"
android:paddingTop="10dp"
android:textColor="#color/yellow"
android:textSize="15sp" />
</RelativeLayout>
<LinearLayout
android:id="#+id/main_item_content_linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:textSize="20sp"
android:textStyle="bold" />
<GridView
android:id="#+id/main_item_pictures"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:numColumns="3"
android:scrollbars="none" >
</GridView>
</LinearLayout>
<RelativeLayout
android:id="#+id/relativeLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp" >
<TextView
android:id="#+id/comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:textSize="12sp" />
<ImageView
android:id="#+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="#id/comment"
android:paddingBottom="10dp"
android:src="#drawable/weibo_comment" />
<TextView
android:id="#+id/transmit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="#id/imageView4"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:textSize="12sp" />
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="#id/transmit"
android:paddingBottom="10dp"
android:src="#drawable/weibo_transmit" />
<TextView
android:id="#+id/praise"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="#id/imageView3"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:textSize="12sp" />
<ImageView
android:id="#+id/imageView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="#id/praise"
android:paddingBottom="10dp"
android:src="#drawable/weibo_transmit" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>

Related

Resize image background keyboard(android)

Sorry for my english. I have background image, if keyboard show is resize background image. If keyboard not show evrithing work fine.
sorry obout image i have not 15 reputation
Its normal condition: image
Its if keyboard is show: image, background image is resize
Its if i in manifest i write adjustPan image
Bellow my xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:background="#9a5f35"
android:layout_height="50dp" >
<LinearLayout
android:id="#+id/edit_profile"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
</LinearLayout>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:text="Получить бонус"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:textSize="20sp" />
<RelativeLayout
android:id="#+id/backDd"
android:layout_width="100dp"
android:layout_height="50dp" >
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:src="#drawable/back_arraund" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom" >
<ScrollView
android:id="#+id/scroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:fadingEdge="none" >
<ImageView
android:id="#+id/imageView21"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="#drawable/bg_shkaf" />
</ScrollView>
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="40dp"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="1) Введите сумму вашего счета"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:textSize="20dp" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="2) Сгенерируйте код"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:textSize="20dp" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="3) Покажите код официанту"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:textSize="20dp" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="4) Получите бонус на счет"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:textSize="20dp" />
</LinearLayout>
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:gravity="center"
android:lineSpacingMultiplier="1.2"
android:text="Бонусы дают привликательную возможность\nполучть скидки и обменивать их на подарки\nот нашего кафе.Получайте как можно больше\nбонусов, для более ценных подарков"
android:textColor="#d2d3ce"
android:textSize="13dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="80dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:text="Введите сумму:"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:textSize="20dp" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1" >
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginRight="10dp"
android:background="#drawable/button_radius_get_bonus"
android:gravity="center_vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/summgrn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:hint="1200"
android:inputType="number"
android:maxLines="1"
android:maxLength="5"
android:background="#null"
android:textColor="#fff"
android:textColorHint="#91623f" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginRight="20dp"
android:layout_weight="1"
android:text="грн."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:textSize="20dp" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:layout_marginTop="1dp"
android:text="и покажите официанту код"
android:textColor="#fff"
/>
<ImageView
android:id="#+id/registrationsdasdad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:src="#drawable/review_button"
android:visibility="invisible" />
<TextView
android:id="#+id/textView102"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="50dp"
android:layout_marginTop="1dp"
android:text="Мы очень старались - оцените нас!"
android:textColor="#fff"
android:visibility="invisible" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
<ImageView
android:id="#+id/imageView212"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_centerHorizontal="true"
android:scaleType="centerCrop"
android:layout_marginTop="10dp"
android:visibility="invisible"
android:src="#drawable/image_8" />
<RelativeLayout
android:id="#+id/generateBonus"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:background="#9a5f35"
android:gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<TextView
android:id="#+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Получить"
android:textColor="#fff"
android:textSize="20dp" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>

Overlaying an imageview relative to another layout

This is what I'm trying to achieve:
I'm trying to add an ImageView (cirlce avatar) which is aligned to the bottom right of the top bar but with an overlay extending below the bar.
Here's what I have so far:
<?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">
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="#ff652c90">
<ImageButton
android:layout_width="25dp"
android:layout_height="25dp"
android:id="#+id/backBtn"
android:src="#drawable/backarrow"
android:background="#android:color/transparent"
android:paddingLeft="10dp"
android:layout_centerVertical="true"
android:scaleType="fitCenter"
android:layout_gravity="center_vertical" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/backBtn"
android:id="#+id/infoLayout"
android:layout_centerVertical="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Lesky"
android:id="#+id/contactName"
android:textColor="#ffffffff"
android:paddingLeft="10dp"
android:textSize="16dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="last online 22/4/2016 11:36 am"
android:id="#+id/lastSeen"
android:layout_below="#id/contactName"
android:textColor="#ffd1d2d4"
android:paddingLeft="10dp"
android:textSize="10dp" />
</RelativeLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:id="#+id/imageView"
android:src="#drawable/contactpiccirlce"
android:scaleType="fitCenter" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/chatView"
android:layout_gravity="center_horizontal" />
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:background="#android:color/black"
android:layout_alignBottom="#id/chatView"
android:id="#+id/postArea">
<EditText
android:layout_width="wrap_content"
android:layout_height="30dp"
android:inputType="textMultiLine"
android:minHeight="30dp"
android:ems="10"
android:id="#+id/editText" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
How can anyone achieve this?
Replace with 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" >
<RelativeLayout
android:id="#+id/firstLayout"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="#ff652c90" >
<ImageButton
android:id="#+id/backBtn"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical"
android:background="#android:color/transparent"
android:paddingLeft="10dp"
android:scaleType="fitCenter"
android:src="#drawable/backarrow" />
<RelativeLayout
android:id="#+id/infoLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="#id/backBtn" >
<TextView
android:id="#+id/contactName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text="Lesky"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ffffffff"
android:textSize="16dp" />
<TextView
android:id="#+id/lastSeen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/contactName"
android:paddingLeft="10dp"
android:text="last online 22/4/2016 11:36 am"
android:textColor="#ffd1d2d4"
android:textSize="10dp" />
</RelativeLayout>
</RelativeLayout>
<ImageView
android:id="#+id/imageView"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:layout_marginTop="35dp"
android:scaleType="fitCenter"
android:src="#drawable/contactpiccirlce" />
<RelativeLayout
android:id="#+id/secondLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/firstLayout" >
<ListView
android:id="#+id/chatView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
<LinearLayout
android:id="#+id/postArea"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_alignBottom="#id/chatView"
android:background="#android:color/black"
android:orientation="vertical" >
<EditText
android:id="#+id/editText"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:ems="10"
android:inputType="textMultiLine"
android:minHeight="30dp" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
How about this:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/infoLayout">
<ImageButton
android:layout_width="25dp"
android:layout_height="25dp"
android:id="#+id/backBtn"
android:src="#drawable/backarrow"
android:background="#android:color/transparent"
android:paddingLeft="10dp"
android:layout_centerVertical="true"
android:scaleType="fitCenter"
android:layout_gravity="center_vertical" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/backBtn"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Lesky"
android:id="#+id/contactName"
android:textColor="#ffffffff"
android:paddingLeft="10dp"
android:textSize="16dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/backBtn"
android:text="last online 22/4/2016 11:36 am"
android:id="#+id/lastSeen"
android:layout_below="#id/contactName"
android:textColor="#ffd1d2d4"
android:paddingLeft="10dp"
android:textSize="10dp" />
</RelativeLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#id/infoLayout"
android:layout_alignTop="#id/infoLayout"
android:padding="10dp"
android:scaleType="center"
android:id="#+id/imageView"
android:src="#drawable/contactpiccirlce"
android:scaleType="fitCenter" />

How to make XML scrollable with multiple listview and increase the size of listview as per entry?

I am having a layout which appears like
I want the page to be scrollabale and list view to add dynamically.
right now when the data is exceeding the page height, I am not able to scroll the page up.
xml is here
<?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" >
<LinearLayout
android:id="#+id/buttonlayout"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:background="#1274B9"
android:gravity="left|top"
android:orientation="horizontal" >
<Button
android:id="#+id/settings"
android:layout_width="54dp"
android:layout_height="match_parent"
android:background="#drawable/backarrow" />
<ImageView
android:id="#+id/prevMonth"
android:layout_width="20dp"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:clickable="true"
android:onClick="prevDate"
android:src="#drawable/calendar_left_arrow_selector" >
</ImageView>
<TextView
android:id="#+id/currentMonth"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_weight="0.6"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" >
</TextView>
<ImageView
android:id="#+id/nextMonth"
android:layout_width="20sp"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_marginRight="10sp"
android:clickable="true"
android:onClick="nextDate"
android:src="#drawable/calendar_right_arrow_selector" >
</ImageView>
<Button
android:id="#+id/addEvent"
android:layout_width="54sp"
android:layout_height="match_parent"
android:background="#drawable/check"
android:onClick="gotomealsactivity" />
</LinearLayout>
<!-- Breakfast portion -->
<RelativeLayout
android:id="#+id/relativebreakfastheading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/buttonlayout"
android:background="#1274B9" >
<TextView
android:id="#+id/breakfastheading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Breakfast"
android:textColor="#ffffff"
android:textSize="20sp" />
<TextView
android:id="#+id/totalcalorieheading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="10dp"
android:gravity="right"
android:textColor="#ffffff"
android:textSize="20sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativebreakfastlist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativebreakfastheading" >
<ListView
android:id="#+id/listbreakfast"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
<TextView
android:id="#+id/addbreakfast"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/listbreakfast"
android:layout_centerHorizontal="true"
android:clickable="true"
android:gravity="center"
android:onClick="gotobreakfastactivity"
android:text="Add Food +"
android:textStyle="bold" />
<View
android:id="#+id/view1"
android:layout_width="fill_parent"
android:layout_height="1dip"
android:layout_alignParentLeft="true"
android:layout_below="#+id/addbreakfast"
android:background="#ff106510" />
</RelativeLayout>
<!-- Lunch portion -->
<RelativeLayout
android:id="#+id/relativelunchheading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativebreakfastlist"
android:background="#1274B9" >
<TextView
android:id="#+id/lunchheading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Lunch"
android:textColor="#ffffff"
android:textSize="20sp" />
<TextView
android:id="#+id/totalcalorielunchheading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="10dp"
android:gravity="right"
android:textColor="#ffffff"
android:textSize="20sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativelunchlist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativelunchheading" >
<ListView
android:id="#+id/listlunch"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
<TextView
android:id="#+id/addlunch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/listlunch"
android:layout_centerHorizontal="true"
android:clickable="true"
android:gravity="center"
android:onClick="gotolunchactivity"
android:text="Add Food +"
android:textStyle="bold" />
<View
android:id="#+id/view2"
android:layout_width="fill_parent"
android:layout_height="1dip"
android:layout_alignParentLeft="true"
android:layout_below="#+id/addlunch"
android:background="#ff106510" />
</RelativeLayout>
<!-- Dinner portion -->
<RelativeLayout
android:id="#+id/relativedinnerheading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativelunchlist"
android:background="#1274B9" >
<TextView
android:id="#+id/dinnerheading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Dinner"
android:textColor="#ffffff"
android:textSize="20sp" />
<TextView
android:id="#+id/totalcaloriedinnerheading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="10dp"
android:gravity="right"
android:textColor="#ffffff"
android:textSize="20sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativedinnerlist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativedinnerheading" >
<ListView
android:id="#+id/listdinner"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
<TextView
android:id="#+id/adddinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/listdinner"
android:layout_centerHorizontal="true"
android:clickable="true"
android:gravity="center"
android:onClick="gotodinneractivity"
android:text="Add Food +"
android:textStyle="bold" />
<View
android:id="#+id/view3"
android:layout_width="fill_parent"
android:layout_height="1dip"
android:layout_alignParentLeft="true"
android:layout_below="#+id/adddinner"
android:background="#ff106510" />
</RelativeLayout>
<!-- Snacks portion -->
<RelativeLayout
android:id="#+id/relativesnacksheading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativedinnerlist"
android:background="#1274B9" >
<TextView
android:id="#+id/snacksheading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Snacks"
android:textColor="#ffffff"
android:textSize="20sp" />
<TextView
android:id="#+id/totalcaloriesnacksheading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="10dp"
android:gravity="right"
android:textColor="#ffffff"
android:textSize="20sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativesnackslist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativesnacksheading" >
<ListView
android:id="#+id/listsnacks"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
<TextView
android:id="#+id/addsnacks"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/listsnacks"
android:layout_centerHorizontal="true"
android:clickable="true"
android:gravity="center"
android:onClick="gotosnacksactivity"
android:text="Add Food +"
android:textStyle="bold" />
<View
android:id="#+id/view4"
android:layout_width="fill_parent"
android:layout_height="1dip"
android:layout_alignParentLeft="true"
android:layout_below="#+id/addsnacks"
android:background="#ff106510" />
</RelativeLayout>
</RelativeLayout>
You can find a screen height and compare it to listBottom - coordinate of some of the ListView's bottom and add new ListViews if needed.
int[] coords = {0,0};
list.getLocationOnScreen(coords);
int listBottom = coords[1] + list.getHeight();
Or problem is that you have no ScrollView in layout?

Make style for single listview item (unwanted scaling)

Hey i wanna make specific single item row for my listView but don't know exacly how to handle it.
i.stack.imgur.com/9fUmX.png
I made something like this using weights on linear layout but it's not working correctly when additional info is too long.
i.stack.imgur.com/uG43j.png
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/transparent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#55000000" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:orientation="horizontal"
android:weightSum="10" >
<!-- pomysle jeszcze nad wagami -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="2" >
<RelativeLayout
android:layout_width="60dp"
android:layout_height="match_parent" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" >
<TextView
android:id="#+id/JsonItemDataNumberOfTheDayFree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="21"
android:textColor="#FFF"
android:textSize="15sp" />
<TextView
android:id="#+id/JsonItemDataMonthFree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/JsonItemDataNumberOfTheDayFree"
android:layout_centerHorizontal="true"
android:text="CZE"
android:textColor="#FFF"
android:textSize="13sp" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="7"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- tu nie jestem pewny margin top? -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/JsonItemTitleEventFree"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:singleLine="true"
android:text="Title"
android:textColor="#android:color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/JsonItemAdditionalInfoFree"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="Additional Info"
android:textColor="#android:color/white"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/JsonItemDateFree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="10dp"
android:text="Date"
android:textColor="#android:color/white"
android:textSize="10sp" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="20dp"
android:layout_height="100dp"
android:layout_weight="1" >
<ImageView
android:id="#+id/JsonItemLogoCategoryFree"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/category_music"
android:scaleType="fitStart" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
try this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#55000000"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="2" >
<RelativeLayout
android:layout_width="60dp"
android:layout_height="match_parent" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" >
<TextView
android:id="#+id/JsonItemDataNumberOfTheDayFree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="21"
android:textColor="#FFF"
android:textSize="15sp" />
<TextView
android:id="#+id/JsonItemDataMonthFree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/JsonItemDataNumberOfTheDayFree"
android:layout_centerHorizontal="true"
android:text="CZE"
android:textColor="#FFF"
android:textSize="13sp" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="7"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_gravity="top"
android:id="#+id/JsonItemTitleEventFree"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:singleLine="true"
android:text="Title"
android:textColor="#android:color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/JsonItemAdditionalInfoFree"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="Additional Info"
android:textColor="#android:color/white"
android:textSize="14sp" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/JsonItemDateFree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="10dp"
android:text="Date"
android:textColor="#android:color/white"
android:textSize="10sp" />
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="20dp"
android:layout_height="100dp"
android:layout_weight="1" >
<ImageView
android:id="#+id/JsonItemLogoCategoryFree"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/category_music"
android:scaleType="fitStart" />
</LinearLayout>

expandable listview scrolling

in my application I have 3 expandableListview as shown here.
<?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:clickable="true"
android:orientation="vertical" >
<LinearLayout
android:layout_width="280dp"
android:layout_height="fill_parent"
android:background="#color/filter_items_background"
android:layout_gravity="end"
android:clickable="true"
android:orientation="vertical" >
<!-- Gender -->
<TextView
android:id="#+id/listSelectionHeaderTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/filter_groups_background"
android:gravity="center_vertical"
android:minHeight="#dimen/filterFragment__itemHeight"
android:paddingLeft="20dp"
android:text="#string/filter_interestedin"
android:textColor="#8F8F8F"
android:textSize="20sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/filter_items_background"
android:minHeight="#dimen/filterFragment__itemHeight"
android:orientation="horizontal"
android:paddingLeft="20dp"
android:paddingRight="10dp" >
<TextView
android:id="#+id/men_itemText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="#string/filter_men"
android:textColor="#android:color/white"
android:textSize="16sp" />
<ToggleButton
android:id="#+id/men_toggleButton"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#drawable/custom_switch_drawable"
android:textOff=""
android:textOn="" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/filter_items_background"
android:minHeight="#dimen/filterFragment__itemHeight"
android:orientation="horizontal"
android:paddingLeft="20dp"
android:paddingRight="10dp" >
<TextView
android:id="#+id/women_itemText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="#string/filter_women"
android:textColor="#android:color/white"
android:textSize="16sp" />
<ToggleButton
android:id="#+id/women_toggleButton"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#drawable/custom_switch_drawable"
android:textOff=""
android:textOn="" />
</RelativeLayout>
<!-- Age -->
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/filter_groups_background"
android:gravity="center_vertical"
android:minHeight="#dimen/filterFragment__itemHeight"
android:orientation="horizontal"
android:paddingRight="10dp" >
<TextView
android:id="#+id/ageHeaderTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:paddingLeft="20dp"
android:text="#string/filter_age"
android:textColor="#8F8F8F"
android:textSize="20sp" />
<TextView
android:id="#+id/ageValuesTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:paddingLeft="20dp"
android:text="Sample"
android:textColor="#android:color/white"
android:textSize="20sp" />
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/filter_items_background"
android:orientation="vertical"
android:paddingLeft="20dp"
android:paddingRight="10dp" >
<SeekBar
android:id="#+id/age_seekBar_from"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<SeekBar
android:id="#+id/age_seekBar_to"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<ExpandableListView
android:id="#+id/expandableListView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cacheColorHint="#00000000"
android:background="#000000"
android:groupIndicator="#android:color/transparent"
android:saveEnabled="true" />
<ExpandableListView
android:id="#+id/expandableListView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cacheColorHint="#00000000"
android:background="#000000"
android:groupIndicator="#android:color/transparent"
android:saveEnabled="true" />
<ExpandableListView
android:id="#+id/expandableListView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cacheColorHint="#00000000"
android:background="#000000"
android:groupIndicator="#android:color/transparent"
android:saveEnabled="true" />
</LinearLayout>
</LinearLayout>
My problem is when I open one of expandablelistview the others expandablelistview not showing... I want open one child of expandablelistview and enable scroll and others expandablelistview.

Categories

Resources