in my app i have a application bar at the top and an tab bar at the bottom. These two are been fixed. Inbetween of them i have place a ViewFipper. Inside the view flipper i have 7 text views, one image views and an 3 image buttons.
Now my problem is i want to show all these inside the space between the application bar and the tab bar in all devices. When i check the layout with 2.7 in QVGA the last buttons get hided behind the tab bar. Whereas in 3.2 in HVGA(ADP2) there are more spaces between the last two image buttons and the tab bar. I want the contents inside the view flipper to be exactly in the middle space, there should not be any scroll view in my layout. How to get this....
Following id my layout design
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="#+id/relativeLayout1"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="#drawable/back" xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout android:layout_width="fill_parent" android:layout_marginBottom="10dp"
android:background="#drawable/graybar" android:layout_height="wrap_content"
android:id="#+id/relativeLayout2">
<TextView android:text="Detail" android:id="#+id/textView1"
android:textSize="24sp" android:layout_centerInParent="true"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
<TextView android:layout_width="wrap_content" android:text="Share Festival"
android:gravity="center" android:textStyle="bold"
android:layout_height="wrap_content" android:id="#+id/DetailShare"
android:layout_alignParentRight="true" android:background="#drawable/share">
</TextView>
</RelativeLayout>
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_below="#+id/relativeLayout2" android:layout_above="#+id/relativeLayout4"
android:id="#+id/flipper" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout android:id="#+id/RLL"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical" android:layout_marginBottom="10dp"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="#+id/LL" android:gravity="center">
<ImageView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="#+id/imageView1"
android:src="#drawable/p144" android:layout_alignParentTop="true">
</ImageView>
</LinearLayout>
<RelativeLayout android:layout_width="fill_parent"
android:layout_below="#+id/LL" android:layout_height="wrap_content"
android:id="#+id/RL1">
<ImageButton android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/detailback"
android:layout_alignParentLeft="true" android:background="#drawable/left">
</ImageButton>
<TextView android:text="Detail" android:id="#+id/textView1"
android:background="#drawable/share" android:textSize="15sp"
android:layout_centerInParent="true" android:gravity="center"
android:maxLines="2" android:layout_height="wrap_content"
android:layout_width="wrap_content">
</TextView>
<ImageButton android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/DetailShare"
android:layout_alignParentRight="true" android:background="#drawable/right">
</ImageButton>
</RelativeLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="#+id/Lq1" android:layout_below="#+id/RL1">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="#+id/L2">
<TextView android:text="date" android:id="#+id/date"
android:textSize="18sp" android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="#+id/L2">
<TextView android:text="Contact : " android:id="#+id/contact"
android:textSize="18sp" android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="#+id/L2">
<TextView android:text="mail" android:id="#+id/mail"
android:textSize="18sp" android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="#+id/L2">
<TextView android:text="phone" android:id="#+id/phone"
android:textSize="18sp" android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="#+id/L2">
<TextView android:text="Hollywood" android:id="#+id/address"
android:textSize="18sp" android:layout_marginTop="5dp" android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="#+id/L2">
<TextView android:text="DeadLine : closed 2011 festival"
android:id="#+id/date" android:textSize="18sp"
android:layout_marginTop="5dp" android:layout_gravity="center" android:layout_height="wrap_content"
android:layout_width="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="#+id/L2">
<TextView android:text="Genre" android:id="#+id/genre"
android:textSize="18sp" android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
</LinearLayout>
</LinearLayout>
<RelativeLayout android:id="#+id/Relativelayoutadd" android:layout_height="wrap_content" android:layout_width="fill_parent"
android:layout_below="#+id/Lq1" android:layout_alignBaseline="#+id/flipper">
<TextView android:text="Add to IPhone calendar" android:id="#+id/calendar"
android:textSize="15sp" android:layout_marginBottom="5dp"
android:layout_alignParentLeft="true"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
<TextView android:text="Add to favorite" android:id="#+id/addtofavorite"
android:textSize="15sp" android:layout_marginBottom="5dp"
android:layout_alignParentRight="true"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</TextView>
</RelativeLayout>
</RelativeLayout>
</ViewFlipper>
<RelativeLayout android:layout_width="fill_parent"
android:layout_gravity="bottom" android:layout_alignParentBottom="true"
android:background="#drawable/applicarion_bar" android:layout_height="wrap_content"
android:id="#+id/relativeLayout4">
<ImageButton android:layout_width="wrap_content"
android:layout_marginLeft="5dp" android:layout_height="wrap_content"
android:id="#+id/detailfestivallist" android:layout_alignParentLeft="true"
android:background="#drawable/festival_btn">
</ImageButton>
<ImageButton android:layout_width="wrap_content"
android:layout_marginLeft="90dp" android:layout_height="wrap_content"
android:id="#+id/detailsearch" android:layout_alignParentLeft="true"
android:background="#drawable/search_btn">
</ImageButton>
<TextView android:layout_width="wrap_content" android:text="MAR 20"
android:textSize="9sp" android:layout_marginLeft="170dp"
android:layout_height="wrap_content" android:id="#+id/detailcalendar"
android:layout_alignParentLeft="true" android:background="#drawable/calendar_btn">
</TextView>
<ImageButton android:layout_width="wrap_content"
android:layout_marginRight="5dp" android:layout_height="wrap_content"
android:id="#+id/detailfavorite" android:layout_alignParentRight="true"
android:background="#drawable/favorite_btn">
</ImageButton>
</RelativeLayout>
</RelativeLayout>
First, you have two different elements called android:id="#+id/date". This might give conflicts, and awkward behavior.
Secondly, the android:id="#+id/RLL" is only used to position items vertically. Therefore consider using a LinearLayout instead.
In general, I think your layout uses too much containers. I've created another layout (and replaced the drawables with colours, since i don't have the drawables) which you might use for inspiration to create a simpler, and flexible layout. As commented by Siva K, you can use the android:layout_weight="1" for the elements in the center (in the LinearLayout) to space them evenly...
Below is an example (only the viewFlipper part, the rest is unchanged)
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_below="#+id/relativeLayout2" android:layout_above="#+id/relativeLayout4"
android:id="#+id/flipper" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:id="#+id/RLL"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- HEADER IMAGE -->
<ImageView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="#+id/imageView1"
android:src="#ff5500" android:layout_alignParentTop="true"
android:layout_centerHorizontal="true">
</ImageView>
<!-- TOP -->
<TextView android:text="Detail" android:id="#+id/textView1"
android:background="#ff0022" android:textSize="15sp"
android:layout_centerInParent="true" android:gravity="center"
android:maxLines="2" android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="#id/imageView1">
</TextView>
<ImageButton android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/detailback"
android:layout_alignParentLeft="true" android:background="#112233"
android:layout_alignTop="#id/textView1">
</ImageButton>
<ImageButton android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/DetailShare"
android:layout_alignParentRight="true" android:background="#55ff22"
android:layout_alignTop="#id/textView1">
</ImageButton>
<!-- MIDDLE -->
<LinearLayout
android:id="#+id/ll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#id/textView1"
android:orientation="vertical"
android:layout_marginBottom="20dp">
<TextView android:text="date" android:id="#+id/date"
android:textSize="18sp" android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true" android:layout_weight="1">
</TextView>
<TextView android:text="Contact : " android:id="#+id/contact"
android:textSize="18sp" android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_centerHorizontal="true" android:layout_weight="1">
</TextView>
<TextView android:text="mail" android:id="#+id/mail"
android:textSize="18sp" android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_centerHorizontal="true" android:layout_weight="1">
</TextView>
<TextView android:text="phone" android:id="#+id/phone"
android:textSize="18sp" android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_centerHorizontal="true" android:layout_weight="1">
</TextView>
<TextView android:text="Hollywood" android:id="#+id/address"
android:textSize="18sp" android:layout_marginTop="5dp" android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_centerHorizontal="true" android:layout_weight="1">
</TextView>
<TextView android:text="DeadLine : closed 2011 festival"
android:id="#+id/date2" android:textSize="18sp"
android:layout_marginTop="5dp" android:layout_gravity="center" android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true" android:layout_weight="1">
</TextView>
<TextView android:text="Genre" android:id="#+id/genre"
android:textSize="18sp" android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_centerHorizontal="true" android:layout_weight="1">
</TextView>
</LinearLayout>
<!-- BOTTOM -->
<TextView android:text="Add to IPhone calendar" android:id="#+id/calendar"
android:textSize="15sp" android:layout_marginBottom="5dp"
android:layout_alignParentLeft="true"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_alignParentBottom="true">
</TextView>
<TextView android:text="Add to favorite" android:id="#+id/addtofavorite"
android:textSize="15sp" android:layout_marginBottom="5dp"
android:layout_alignParentRight="true"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_alignParentBottom="true">
</TextView>
</RelativeLayout>
</ViewFlipper>
Hope this works for you.
Related
I have tried LinearLayout inside which I put several textview. I completely use weights for each and every view. Problem arises when data becomes too much in lenght and textview not shows it completely. I also tried tabletlayout but that thing also not works beacuse ultimately tablelayout is inside linear layout having weight,so it doesn't grows beyond a certain limit. I want to know how can I make a activity scrollable with showing all data while using weights.
Use Scrollview in xml Layout of your activity.
Example:
XML code for your activity:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp"
android:fillViewport="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:scaleType="centerCrop"
android:src="#drawable/image" />
<Button
android:id="#+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="KNOW MORE" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/title"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/description"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</ScrollView>
You can Use Scroll View With Linear Layout as well as With Relative layout.
You Can try this code, Just Copy and paste in XML File.
U'll Get Your ans :)
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:background="#android:color/black"
>
<TextView
android:id="#+id/TV_Welcome"
android:text="ADD YOUR VEHICLE"
android:layout_marginLeft="70dp"
android:layout_marginTop="10dp"
android:textSize="20dp"
android:layout_centerHorizontal="true"
android:textColor="#color/menu_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"/>
<RelativeLayout
android:id="#+id/RelativeLayout01"
android:layout_below="#+id/TV_Welcome"
android:layout_margin="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/TV_BlockNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Block No:"
android:textColor="#color/version_color"
android:layout_marginLeft="10dp"
android:textSize="15dp"
android:layout_alignParentLeft="true"
android:gravity="left"
/>
<Spinner
android:id="#+id/Spinner_BlockNo"
android:layout_marginLeft="30dp"
android:layout_toRightOf="#+id/TV_BlockNo"
android:background="#558cff"
android:layout_width="300dp"
android:layout_height="wrap_content">
</Spinner>
</RelativeLayout>
<RelativeLayout
android:id="#+id/RelativeLayout02"
android:layout_margin="10dp"
android:layout_below="#+id/RelativeLayout01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/TV_FlatNo"
android:text="Flat NO:"
android:textSize="15dp"
android:layout_marginLeft="10dp"
android:textColor="#color/version_color"
/>
<Spinner
android:id="#+id/Spinner_FlatNo"
android:layout_marginLeft="42dp"
android:layout_toRightOf="#+id/TV_FlatNo"
android:background="#558cff"
android:layout_width="300dp"
android:layout_height="wrap_content"></Spinner>
</RelativeLayout>
<RelativeLayout
android:id="#+id/RelativeLayout03"
android:layout_below="#+id/RelativeLayout02"
android:layout_margin="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/TV_VehicleNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Vehicle No:"
android:textColor="#color/version_color"
android:layout_marginLeft="10dp"
android:textSize="15dp"
android:layout_alignParentLeft="true"
android:gravity="left"
/>
<EditText
android:id="#+id/ET_VehicleNo"
android:layout_marginLeft="20dp"
android:hint="Enter Vehicle No"
android:textColorHint="#color/menu_glow"
android:textSize="20dp"
android:layout_toRightOf="#+id/TV_VehicleNo"
android:textColor="#558cff"
android:layout_width="400dp"
android:layout_height="wrap_content"
/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/RelativeLayout04"
android:layout_margin="10dp"
android:layout_below="#+id/RelativeLayout03"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/TV_VehicleType"
android:text="Vehicle Type:"
android:textSize="15dp"
android:layout_marginLeft="10dp"
android:textColor="#color/version_color"
/>
<Spinner
android:id="#+id/Spinner_VehicleType"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/TV_VehicleType"
android:background="#558cff"
android:layout_width="300dp"
android:layout_height="wrap_content">
</Spinner>
</RelativeLayout>
<RelativeLayout
android:id="#+id/RelativeLayout05"
android:layout_margin="10dp"
android:layout_below="#id/RelativeLayout04"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/TV_OwnerName"
android:text="Owner Name:"
android:textSize="15dp"
android:textColor="#color/version_color"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:gravity="left">
</TextView>
<EditText
android:id="#+id/ET_OwnerName"
android:hint="Enter Owner Name"
android:textColorHint="#color/menu_glow"
android:inputType="textPersonName"
android:layout_marginLeft="20dp"
android:textSize="20dp"
android:layout_toRightOf="#id/TV_OwnerName"
android:textColor="#color/version_color"
android:layout_height="wrap_content"
android:layout_width="400dp">
</EditText>
</RelativeLayout>
<RelativeLayout
android:id="#+id/RelativeLayout06"
android:layout_margin="10dp"
android:layout_below="#id/RelativeLayout05"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/TV_MobileNo"
android:text="Mobile No:"
android:textSize="15dp"
android:textColor="#color/version_color"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:gravity="left">
</TextView>
<EditText
android:id="#+id/ET_MobileNo"
android:layout_marginLeft="40dp"
android:hint="Enter 10 digit"
android:textColorHint="#color/menu_glow"
android:inputType="phone"
android:textSize="20dp"
android:layout_toRightOf="#id/TV_MobileNo"
android:textColor="#color/version_color"
android:layout_height="wrap_content"
android:layout_width="200dp"
>
</EditText>
</RelativeLayout>
<RelativeLayout
android:id="#+id/RelativeLayout07"
android:layout_margin="10dp"
android:layout_below="#id/RelativeLayout06"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/TV_TelNo"
android:text="Telephone No:"
android:textSize="15dp"
android:textColor="#color/version_color"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
</TextView>
<EditText
android:id="#+id/ET_TelNo"
android:layout_marginLeft="20dp"
android:hint="Enter Telephone No"
android:textColorHint="#color/menu_glow"
android:inputType="number"
android:textSize="17dp"
android:layout_toRightOf="#id/TV_TelNo"
android:textColor="#color/version_color"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
</EditText>
</RelativeLayout>
<RelativeLayout
android:id="#+id/RelativeLayout08"
android:layout_margin="0dp"
android:layout_below="#id/RelativeLayout07"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/TV_Example"
android:text="(Example:0141-2206923)"
android:layout_marginLeft="120dp"
android:textSize="10dp"
android:textColor="#color/version_color"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
</TextView>
</RelativeLayout>
<ImageView
android:id="#+id/ImageView_Submit"
android:layout_marginTop="5dp"
android:layout_marginLeft="100dp"
android:layout_centerInParent="true"
android:layout_width="150dp"
android:layout_height="150dp"
android:src="#drawable/submit"
android:layout_below="#id/RelativeLayout08"
android:onClick="doSubmit"></ImageView>
</RelativeLayout>
</ScrollView>
You can make your activity scrollable using ScrollView.
Its very simple and effective to use.Just copy code of ScrollView from below and paste it in your layout xml file.
You can use this ScrollView with Linear as well as Relative Layout also.
Just need to remember one thing,ScrollView can have only one child widget.If you want more Children then wrap them into one container.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/xyz.png"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView1"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView2"/>
<TextView
android:id="#+id/textView3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView3"/>
<TextView
android:id="#+id/textView4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView4"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/btn_demo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Demo" />
</LinearLayout>
</LinearLayout>
</ScrollView>
There is a list view and other text views in my screen.
I want to show the list in whole the screen and other elements in the bottom of the list.
Below is the code I used.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relative_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background_light_blue" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background_light_blue"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/header1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#layout/header_gradients"
android:orientation="vertical"
android:paddingBottom="8dip"
android:paddingTop="8dip" >
<TextView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_marginLeft="10dip"
android:layout_weight="1"
android:gravity="center"
android:text="#string/shopping_cart"
android:textColor="#color/white"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/background_light_blue"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginTop="5dip"
android:background="#color/white"
android:orientation="horizontal"
android:padding="5dp" >
<TextView
android:id="#+id/purchase_order"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginTop="2dp"
android:text="Requisitioner"
android:textColor="#color/black"
android:textSize="15sp"
android:typeface="sans" />
<TextView
android:id="#+id/requisitioner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/purchase_order"
android:layout_marginBottom="3dp"
android:layout_marginLeft="6dp"
android:layout_marginTop="5dp"
android:text="Requisitioner"
android:textColor="#color/black"
android:textSize="15sp" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:contentDescription="#string/image"
android:src="#drawable/shopping_cart" />
</RelativeLayout>
<TextView
android:id="#+id/products_and_services"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginTop="15dp"
android:gravity="center_horizontal"
android:text="#string/products_and_services"
android:textColor="#color/black"
android:textSize="17sp"
android:textStyle="bold" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:id="#+id/lr1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ListView
android:id="#android:id/list"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="0.12" >
</ListView>
</LinearLayout>
<LinearLayout
android:id="#+id/pagingPanel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/lr1"
android:background="#drawable/background_light_blue"
android:orientation="vertical" >
<TextView
android:id="#+id/note_to_approver"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:text="#string/note_to_approver"
android:textColor="#color/black"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="#+id/note"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="2dp"
android:background="#color/white"
android:maxLines="10"
android:padding="5dp"
android:text="hijnjn"
android:textColor="#color/black"
android:textSize="15sp"
android:typeface="sans" />
<TextView
android:id="#+id/approver"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginTop="15dp"
android:gravity="center_horizontal"
android:text="#string/approvers"
android:textColor="#color/black"
android:textSize="17sp"
android:textStyle="bold" />
<Button
android:id="#+id/approvers"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/options_menu"
android:drawableRight="#drawable/arrow_right"
android:gravity="left|center"
android:text="#string/approvers"
android:textColor="#color/black"
android:textSize="16sp"
android:textStyle="bold"
android:typeface="sans" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:id="#+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#layout/btn_background" >
<Button
android:id="#+id/release_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:background="#drawable/btn_blue"
android:text="Approve(1)/Reject(0)"
android:textColor="#color/white"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
My requirement: Now the list is scrolling within the given area. I want to show in the whole screen and the scrolling should be only for the screen.
Please help me to do this.
You should not put a Vertically scrolling widget/view (ListView) in another vertically scrolling view (ScrollView). Though there are a few ways mentioned here and here which might help you achieve what you wish but that will increase the CPU load.
i tried designing an xml layout for my android app. It looks good in eclipse graphical layout of android api level 10. But when i run the same in my android device of 2.3.3(api level 10),
that layout looks completely different.
After the text title in the top everything gets changed
I have attached the screen shot of my graphical layout in eclipse and image from my android device
Following is my xml file
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/frame2_include"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#drawable/bg">
<LinearLayout
android:id="#+id/title_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top">
<include
android:id="#+id/title_include"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="#layout/title" />
</LinearLayout>
<RelativeLayout
android:id="#+id/r_title_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/title_bg">
<TextView
android:id="#+id/normal_title_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/app"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/r_frame_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/r_title_layout">
<ViewSwitcher
android:id="#+id/r_frame_viewSwitcher1"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/r_frame_image_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="7dp"
android:background="#color/white"
android:layout_gravity="center_vertical">
<RelativeLayout
android:id="#+id/r_round_points"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/points_bg" >
<LinearLayout
android:id="#+id/r_center_frame_img_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<TextView
android:id="#+id/r_frame_img_txt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30dp"
android:text="50"
android:textColor="#000000"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/r_frame_img_txt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Points"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/r_frame_map_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include
android:id="#+id/parii_me_map_view2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
layout="#layout/parii_map" />
</LinearLayout>
</ViewSwitcher>
<RelativeLayout
android:id="#+id/r_merge_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="105dp"
android:background="#android:color/transparent">
<ImageView
android:contentDescription="#string/app_name"
android:id="#+id/merge_bg_img"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/title_bg"
android:layout_centerInParent="true"/>
<RelativeLayout
android:id="#+id/merge_view_pro_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/merge_center_img"
android:layout_centerVertical="true">
<TextView
android:id="#+id/merge_view_pro_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/mrg_profile"
android:layout_centerInParent="true"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
<ImageView
android:contentDescription="#string/app_name"
android:id="#+id/merge_center_img"
android:layout_width="73dp"
android:layout_height="73dp"
android:layout_centerInParent="true"
android:background="#drawable/ic_launcher" />
<RelativeLayout
android:id="#+id/merge_view_cash_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/merge_center_img"
android:layout_centerVertical="true">
<TextView
android:id="#+id/merge_view_cash_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="#string/mrg_cash"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/r_edit_box_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="185dp">
<TextView
android:id="#+id/r_remaining_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="7dp"
android:layout_marginRight="3dp"
android:gravity="center|center_horizontal"
android:text="200"
android:textColor="#color/black"
android:background="#drawable/ponts_field"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/r_remaining_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/r_remaining_label"
android:text="#string/Reamins"
android:layout_centerVertical="true"
android:textColor="#color/black"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/r_points_txt"
android:layout_toLeftOf="#+id/r_points_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Parii_Pts"
android:layout_centerVertical="true"
android:gravity="center"
android:textColor="#color/black"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/r_points_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="7dp"
android:layout_marginLeft="3dp"
android:text="100"
android:gravity="center|center_horizontal"
android:textColor="#color/black"
android:background="#drawable/ponts_field"
android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>
</RelativeLayout>
<TextView
android:id="#+id/r_items_viewed_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="10dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_below="#+id/r_frame_layout"
android:maxLines="2"
android:textColor="#color/black"
android:textAppearance="?android:attr/textAppearanceSmall" />
<RelativeLayout
android:id="#+id/r_bottom_map_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/r_items_viewed_txt"
android:layout_marginTop="20dp">
<TextView
android:id="#+id/r_valid_date"
android:layout_toLeftOf="#+id/r_points_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:textColor="#color/black"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageButton
android:contentDescription="#string/app_name"
android:id="#+id/parii_me_details_switch_mapBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:layout_centerVertical="true"
android:background="#drawable/map_sel_btn" />
</RelativeLayout>
</FrameLayout>
Pls say me where i am going wrong
try this:
only replace that by default image by your circle image having 50 pts inside.
<?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="#aba4a4">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/l1">
<Button
android:id="#+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Back btn"
android:textColor="#121212"
android:textSize="18dp" />
<TextView
android:id="#+id/txt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Rewards"
android:textColor="#android:color/black"
android:textSize="18dp"
android:textStyle="bold"
android:layout_gravity="center_vertical"
android:layout_marginLeft="15dp"/>
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/l2"
android:layout_below="#+id/l1"
android:background="#7d7373">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
android:textSize="18dp"
android:layout_centerHorizontal="true"
android:textColor="#android:color/white"/>
</RelativeLayout>
<ImageView
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_below="#+id/l2"
android:background="#drawable/ic_launcher"/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/l3"
android:background="#7d7373"
android:layout_centerInParent="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Profile"
android:textSize="18dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:textColor="#android:color/white"
android:layout_marginLeft="20dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="View"
android:textSize="18dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:textColor="#android:color/white"
android:layout_marginRight="20dp"/>
</RelativeLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_launcher"
android:layout_centerInParent="true"/>
</RelativeLayout>
Add the remaining view in it.i think this must solve your issue.
I have an image of some restaurant and under that some info of that restaurant. Under all of that i have some listView with some menu (what is on discount)... My problem is this: Before listView i have an textView with a description of that restaurant. It can be different sizes for different restaurants, and because of that sometimes my listView isn't showing on screen. I tried to put ScrollView, but it was bad idea... What can I do??? ANy sugestion??? Here is my code:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="100"
android:keepScreenOn="true">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="50"
android:id="#+id/linearLayoutOne1">
<ImageView android:layout_width="0dip"
android:layout_height="wrap_content"
android:src="#drawable/marker_a"
android:id="#+id/imageView1"
android:layout_weight="1"
android:scaleType="fitStart"
android:layout_gravity="center"
>
</ImageView>
</LinearLayout>
<ScrollView
android:id="#+id/widgetOne"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="50"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:text="Ime restorana"
android:textSize="20sp"
android:id="#+id/textViewImeRestorana"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:background="#5E5E5E">
</TextView>
<TextView android:text=""
android:id="#+id/textViewAdresa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<TextView android:text="#string/daljina"
android:id="#+id/textViewDaljina"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<TextView
android:text=""
android:id="#+id/textViewNista"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<TextView android:text="#string/radno_vreme_"
android:id="#+id/textViewRadnoVreme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<TextView android:text="#string/pon_nedelja"
android:id="#+id/textViewPonSub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<TextView android:text="Nedelja"
android:id="#+id/textViewNedelja"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<TextView android:text="#string/pozovite_nas_"
android:id="#+id/textViewPozovite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<Button android:text="Pozovi"
android:id="#+id/buttonPozovi"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="12sp"
android:layout_weight="1">
</Button>
<TextView android:text="Opis"
android:id="#+id/textViewOpis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textColor="#5E5E5E"
android:background="#drawable/border">
</TextView>
<TextView android:text="#string/specijalna_ponuda"
android:id="#+id/textViewSpecijalnaPonuda"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp">
</TextView>
<TextView android:text=""
android:id="#+id/textViewPonudeNema"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:textSize="14sp">
</TextView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="#+id/listViewPonuda"
android:layout_width="fill_parent"
android:smoothScrollbar="true"
android:visibility="visible"
android:layout_height="70dip"
android:textSize="14sp">
</ListView>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
Placing ListView or ScrollView on another List/ScrollView doesn't work properly.
You can use ListView#addHeaderView(View view) to add the description of the restaurant. This behaves as one more row at the top of the list which doesn't need to be similar to the other rows defined in adapter.
In you xml file you used the layourt height as fill_parent in the inner layout.So that it behaves like that.
try this code
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="Vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="100"
android:keepScreenOn="true">
<ImageView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:src="#drawable/marker_a"
android:id="#+id/imageView1"
android:layout_weight="1"
android:scaleType="fitStart"
android:layout_gravity="center"
/>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:text="Ime restorana"
android:textSize="20sp"
android:id="#+id/textViewImeRestorana"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:background="#5E5E5E">
</TextView>
<TextView android:text=""
android:id="#+id/textViewAdresa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<TextView android:text="#string/daljina"
android:id="#+id/textViewDaljina"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<TextView
android:text=""
android:id="#+id/textViewNista"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<TextView android:text="#string/radno_vreme_"
android:id="#+id/textViewRadnoVreme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<TextView android:text="#string/pon_nedelja"
android:id="#+id/textViewPonSub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<TextView android:text="Nedelja"
android:id="#+id/textViewNedelja"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<TextView android:text="#string/pozovite_nas_"
android:id="#+id/textViewPozovite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_weight="1">
</TextView>
<Button android:text="Pozovi"
android:id="#+id/buttonPozovi"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="12sp"
android:layout_weight="1">
</Button>
<TextView android:text="Opis"
android:id="#+id/textViewOpis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textColor="#5E5E5E"
android:background="#drawable/border">
</TextView>
<TextView android:text="#string/specijalna_ponuda"
android:id="#+id/textViewSpecijalnaPonuda"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp">
</TextView>
<TextView android:text=""
android:id="#+id/textViewPonudeNema"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:textSize="14sp">
</TextView>
<ListView
android:id="#+id/listViewPonuda"
android:layout_width="fill_parent"
android:smoothScrollbar="true"
android:visibility="visible"
android:layout_height="70dip"
android:textSize="14sp"/>
</LinearLayout>
</LinearLayout>
I have a linear layout, and inside that I have a webview and a relative layout. I want the webview to take up all the free space and let the relative layout keep it's height wrapped on the content.
I tried multiple ways but I still couldn't get it working properly.
Could someone explain to me how I could make the webview take up all the free space and keep my relative layout at the bottom with it's content wrapped.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:background="#drawable/titlebar_top">
<ImageView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:background="#drawable/logo"
android:layout_centerHorizontal="true" android:layout_centerVertical="true">
</ImageView>
<ImageButton android:layout_height="wrap_content"
android:layout_width="wrap_content" android:background="#drawable/redarrowright"
android:layout_alignParentRight="true" android:layout_centerVertical="true"
android:id="#+id/imgArticlePrevious" android:layout_marginRight="10dip">
</ImageButton>
<ImageButton android:id="#+id/imgArticleRight"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:background="#drawable/redarrowleft"
android:layout_centerVertical="true" android:layout_toLeftOf="#+id/imgArticlePrevious"
android:layout_marginRight="10dip">
</ImageButton>
</RelativeLayout>
<TextView
android:id= "#+id/txtTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Le soleisl sssssssssssssssss"
android:layout_gravity="center_horizontal"
android:textSize="22sp"
android:gravity="center"
android:textStyle="bold"
android:maxLines="2">
</TextView>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/txtCategory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Info"
android:textColor="#color/red">
</TextView>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="|">
</TextView>
<TextView android:id="#+id/txtDate" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="26/03/2011"
android:textColor="#color/gray">
</TextView>
</LinearLayout>
<WebView android:id="#+id/webview" android:layout_width="fill_parent"
android:layout_height="fill_parent" layout_weight="90" />
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="#drawable/articlebanner"
android:layout_gravity="bottom"
android:layout_weight="10">
<ImageButton android:id="#+id/imgComment"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:background="#drawable/commenticon"
android:layout_centerVertical="true">
</ImageButton>
<Button android:id="#+id/txtCommentCount"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:background="#drawable/commentbackground"
android:layout_marginLeft="10dip" android:text="4" android:textColor="#color/white"
android:textStyle="bold" android:layout_alignTop="#+id/imgComment">
</Button>
<Button android:id="#+id/imgShare" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:background="#drawable/buttonshare"
android:layout_alignParentRight="true" android:layout_centerVertical="true"
android:layout_marginRight="2dip" android:drawableLeft="#drawable/sharebtnicon"
android:drawablePadding="2dip" android:text="Partagez"
android:textColor="#color/white" android:textStyle="bold">
</Button>
</RelativeLayout>
Webview - Takes up all the space remaining space between other widgets located at the top and bottom
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:background="#drawable/titlebar_top">
<ImageView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:background="#drawable/logo"
android:layout_centerHorizontal="true" android:layout_centerVertical="true">
</ImageView>
<ImageButton android:layout_height="wrap_content"
android:layout_width="wrap_content" android:background="#drawable/redarrowright"
android:layout_alignParentRight="true" android:layout_centerVertical="true"
android:id="#+id/imgArticlePrevious" android:layout_marginRight="10dip">
</ImageButton>
<ImageButton android:id="#+id/imgArticleRight"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:background="#drawable/redarrowleft"
android:layout_centerVertical="true" android:layout_toLeftOf="#+id/imgArticlePrevious"
android:layout_marginRight="10dip">
</ImageButton>
</RelativeLayout>
<TextView
android:id= "#+id/txtTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:layout_gravity="center_horizontal"
android:textSize="22sp"
android:gravity="center"
android:textStyle="bold"
android:maxLines="2">
</TextView>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/txtCategory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Info"
android:textColor="#color/red">
</TextView>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="|">
</TextView>
<TextView android:id="#+id/txtDate" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="26/03/2011"
android:textColor="#color/gray">
</TextView>
</LinearLayout>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent">
<WebView android:id="#+id/webview" android:layout_width="fill_parent"
android:layout_height="fill_parent" layout_weight="1"
android:layout_above="#+id/sharebar" />
<RelativeLayout
android:id="#+id/sharebar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/articlebanner"
android:layout_gravity="bottom" android:layout_alignParentBottom="true">
<ImageButton android:id="#+id/imgComment"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:background="#drawable/commenticon"
android:layout_centerVertical="true">
</ImageButton>
<Button android:id="#+id/txtCommentCount"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:background="#drawable/commentbackground"
android:layout_marginLeft="10dip" android:text="4" android:textColor="#color/white"
android:textStyle="bold" android:layout_alignTop="#+id/imgComment">
</Button>
<Button android:id="#+id/imgShare" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:background="#drawable/buttonshare"
android:layout_alignParentRight="true" android:layout_centerVertical="true"
android:layout_marginRight="2dip" android:drawableLeft="#drawable/sharebtnicon"
android:drawablePadding="2dip" android:text="Partagez"
android:textColor="#color/white" android:textStyle="bold">
</Button>
</RelativeLayout>
</RelativeLayout>
Solved, I put it in another relative layout, aligned the bar at the bottom and set the webview above it. Worked :)