how to put tabs inside header of the listview? - android

I have a listView with an header which contain imageview, bunch of textviews . But now i want to put two tabs at the bottom of that header to change the content of the listview with those two tabs, I am using Sherlockfragments in my app and the whole listview and its header are in one of my fragment .
This is my header of the listview , right now i am using two buttons instead of tabs but i want to replace them with tabs
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#drawable/purple_bg"
android:orientation="vertical" >
<ImageView
android:id="#+id/userimage_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:src="#drawable/loader" />
<TextView
android:id="#+id/fullname_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/userimage_profile"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:text="ladygaga"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="15sp" />
<TextView
android:id="#+id/twittername_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/fullname_profile"
android:layout_centerHorizontal="true"
android:text="ladygaga"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="10sp" />
<TextView
android:id="#+id/profile_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/twittername_profile"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="8dp"
android:gravity="center"
android:maxLines="2"
android:text="By modifying the URL, dsfhieor fergieirgh erjogw54ijg you can retrieve other variant sizings such as ""
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="13sp" />
<ImageButton
android:id="#+id/find_people"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/profile_text"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:background="#null"
android:onClick="onClick"
android:src="#drawable/find_people" />
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:orientation="horizontal" >
<TextView
android:id="#+id/chance_selected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_weight="1"
android:background="#drawable/chances_selected"
android:gravity="center"
android:scaleType="centerCrop"
android:text="Chances(100)"
android:textSize="15sp" />
<TextView
android:id="#+id/fav_unselect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/fav_unselected"
android:gravity="center"
android:scaleType="centerCrop"
android:text="Favourites"
android:textSize="15sp" />
</LinearLayout>
<TextView
android:id="#+id/follow_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/find_people"
android:layout_marginRight="10dp"
android:layout_toRightOf="#+id/userimage_profile"
android:background="#drawable/follow_reqchance"
android:gravity="center"
android:text="Follow"
android:textColor="#ffffff" />
<TextView
android:id="#+id/req_chance_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/find_people"
android:layout_marginLeft="10dp"
android:layout_toLeftOf="#+id/userimage_profile"
android:background="#drawable/follow_reqchance"
android:gravity="center"
android:text="Request Chance"
android:textColor="#ffffff" />
</RelativeLayout>

Related

put overlapping image between horizontal relative layout

Expected Result
Achieved Result
i am able to acheive everything but not able to place image (+ sign) between two layouts as described.
Following is the code i have used. i am not getting idea how should i place ( + sign image ) overlapping between two relative layouts.
I have tried placing imageview between 2 layouts but it takes space between layouts , i want overlapping between 2 layouts.
If anyone has come across such situation before or can help figure out this problem i would be very much grateful to them. thanks in advance.
<LinearLayout
android:id="#+id/line3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/indicator"
android:orientation="horizontal"
android:weightSum="4">
<RelativeLayout
android:id="#+id/line3_1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#CCCCCC"
android:padding="#dimen/line3_layout_padding">
<TextView
android:id="#+id/textRent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Rent"
android:textColor="#999999"
android:textSize="#dimen/line3_text1_size" />
<TextView
android:id="#+id/textRentValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textRent"
android:layout_centerHorizontal="true"
android:text="€30.00"
android:textColor="#999999"
android:textSize="#dimen/line3_text2_size" />
<TextView
android:id="#+id/textRentPerDay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textRentValue"
android:layout_centerHorizontal="true"
android:text="Per day"
android:textColor="#999999"
android:textSize="#dimen/line3_text1_size" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/line3_2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#FF3333"
android:gravity="center"
android:padding="#dimen/line3_layout_padding">
<TextView
android:id="#+id/textIns"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Insurance"
android:textColor="#FFFFFF"
android:textSize="#dimen/line3_text1_size" />
<TextView
android:id="#+id/textInsValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textIns"
android:layout_centerHorizontal="true"
android:text="€4.00"
android:textColor="#FFFFFF"
android:textSize="#dimen/line3_text2_size" />
<TextView
android:id="#+id/textInsPerDay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textInsValue"
android:layout_centerHorizontal="true"
android:text="Per day"
android:textColor="#FFFFFF"
android:textSize="#dimen/line3_text1_size" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.2"
android:background="#33CC66"
android:gravity="center"
android:padding="#dimen/line3_layout_padding">
<TextView
android:id="#+id/textEbysComm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Ebys commission"
android:textColor="#FFFFFF"
android:textSize="#dimen/line3_text1_size" />
<TextView
android:id="#+id/textEbysCommValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textEbysComm"
android:layout_centerHorizontal="true"
android:text="€2.00"
android:textColor="#FFFFFF"
android:textSize="#dimen/line3_text2_size" />
<TextView
android:id="#+id/textEbysCommPerDay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textEbysCommValue"
android:layout_centerHorizontal="true"
android:text="Per day"
android:textColor="#FFFFFF"
android:textSize="#dimen/line3_text1_size" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:background="#6666CC"
android:gravity="center"
android:padding="#dimen/line3_layout_padding">
<TextView
android:id="#+id/textTotalCost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Total Cost"
android:textColor="#FFFFFF"
android:textSize="#dimen/line3_text1_size" />
<TextView
android:id="#+id/textTotalCostValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textTotalCost"
android:layout_centerHorizontal="true"
android:text="€36.00"
android:textColor="#FFFFFF"
android:textSize="#dimen/line3_text2_size" />
<TextView
android:id="#+id/textTotalCostPerDay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textTotalCostValue"
android:layout_centerHorizontal="true"
android:text="Per day"
android:textColor="#FFFFFF"
android:textSize="#dimen/line3_text1_size" />
</RelativeLayout>
</LinearLayout>
create three individual layouts as below and place them between RelativeLayouts as
XML for sub type
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="60dp">
<View
android:layout_width="30dp"
android:background="#F00"
android:layout_alignParentLeft="true"
android:layout_height="match_parent"/>
<View
android:layout_width="30dp"
android:background="#0F0"
android:layout_alignParentRight="true"
android:layout_height="match_parent"/>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:scaleType="fitCenter"
android:layout_centerInParent="true"
android:src="#android:drawable/ic_dialog_info"/>
</RelativeLayout>

How to set my scrollView layout height to the top of a fragment

I have an app where the scrolView (relative layout inside it) take up the whole screen (fill_parent). But instead of ending at the end of the phone i would like to have a fragment at the bottom and have the ScrollView layout to stop at the top of the fragment. I think it probably has to do with the height but can't really figure out the code. Please look at my imgur image to get my idea. Imgur_Image, press here
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"><![CDATA[
tools:context="c.timno.smsgsm.MainActivity">
]]>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="status?"
android:id="#+id/skicka"
android:hint="Status?"
android:layout_marginTop="38dp"
android:layout_below="#+id/buttonanvandare"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="på"
android:id="#+id/skickaaon"
android:layout_marginEnd="36dp"
android:layout_below="#+id/textViewlarm"
android:layout_alignEnd="#+id/skicka" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Av"
android:id="#+id/skickaaoff"
android:layout_below="#+id/textViewlarm"
android:layout_toEndOf="#+id/skickarela1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Relä 1"
android:id="#+id/skickarela1"
android:layout_alignTop="#+id/skickarela2"
android:layout_alignStart="#+id/skickaaon" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Relä 2"
android:id="#+id/skickarela2"
android:layout_below="#+id/textView"
android:layout_toEndOf="#+id/skickarela1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Aktivera"
android:gravity="center"
android:textSize="29dp"
android:id="#+id/textView"
android:layout_below="#+id/skickaaon"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Larm"
android:textSize="29dp"
android:id="#+id/textViewlarm"
android:layout_below="#+id/skicka"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Avaktivera"
android:textSize="29dp"
android:id="#+id/textView3"
android:autoText="false"
android:layout_below="#+id/textView"
android:layout_alignEnd="#+id/buttoninstallator"
android:layout_marginTop="46dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Relä 1"
android:id="#+id/skickatrela1off"
android:layout_below="#+id/textView3"
android:layout_toStartOf="#+id/skickatrela2off" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Relä 2"
android:id="#+id/skickatrela2off"
android:layout_alignTop="#+id/skickatrela1off"
android:layout_alignStart="#+id/skickarela2" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Användare"
android:id="#+id/buttonanvandare"
android:layout_alignParentStart="true"
android:layout_toStartOf="#+id/skickaaoff" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Installation"
android:id="#+id/buttoninstallator"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_toEndOf="#+id/buttonanvandare" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="status?"
android:id="#+id/statustxt"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="aon"
android:id="#+id/aon"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="aoff"
android:id="#+id/aoff"
android:layout_alignParentStart="true"
android:layout_below="#+id/statustxt" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="on*1*"
android:id="#+id/rela1txxt"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="On*2*"
android:id="#+id/rela2onn"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="off*2*"
android:id="#+id/rela2offtxt"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="off*1*"
android:id="#+id/offrela1txt"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Värmestyrning"
android:textSize="33dp"
android:id="#+id/textView8"
android:layout_below="#+id/skickatrela1off"
android:layout_marginTop="25dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Komfortvärme"
android:textSize="29dp"
android:id="#+id/textView9"
android:layout_below="#+id/textView8" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Heaton"
android:id="#+id/btnHeaton"
android:layout_below="#+id/textView9"
android:layout_alignEnd="#+id/skickatrela1off" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Heatoff"
android:id="#+id/btnHeatoff"
android:layout_below="#+id/textView9"
android:layout_alignStart="#+id/skickatrela2off" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Underhållsvärme"
android:textSize="29dp"
android:id="#+id/textView10"
android:layout_below="#+id/btnHeaton"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Termon"
android:id="#+id/btnTermon"
android:layout_below="#+id/textView10"
android:layout_toStartOf="#+id/btnHeatoff" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Termoff"
android:id="#+id/btnTermoff"
android:layout_alignBottom="#+id/btnTermon"
android:layout_toEndOf="#+id/btnTermon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Heaton"
android:id="#+id/txtHeaton"
android:layout_alignTop="#+id/statustxt"
android:layout_alignEnd="#+id/statustxt" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Heatoff"
android:id="#+id/txtHeatoff"
android:layout_alignBottom="#+id/statustxt"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Termon"
android:id="#+id/txtTermon"
android:layout_alignBaseline="#+id/aoff"
android:layout_alignBottom="#+id/aoff"
android:layout_alignEnd="#+id/statustxt" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Termoff"
android:id="#+id/txtTermoff"
android:layout_alignTop="#+id/statustxt"
android:layout_alignEnd="#+id/txtHeatoff" />
<fragment
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:name="c.timno.smsgsm20.SecondFragment"
android:id="#+id/fragmentsms"
android:layout_below="#+id/textView8"
android:layout_alignParentStart="true"
tools:layout="#layout/second_layout"
android:layout_above="#+id/textView10" />
</RelativeLayout>
</ScrollView>
I would suggest putting the ScrollView and the Fragment inside a new top-level element and then using the respective method within that element to adjust the size and position of each.
For instance, using a RelativeLayout:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
...>
<ScrollView
android:id="#+id/scrollview"
android:layout_above="#+id/frag"
android:layout_width="match_parent"
android:layout_height="match_parent"
...>
<RelativeLayout
android:paddingBottom="50dp"
...>
...
</RelativeLayout>
...
</ScrollView>
<Fragment
android:id="#+id/frag"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="50dp"
...>
...
</Fragment>
</RelativeLayout>
(Note that the padding on the bottom of the RelativeLayout inside the ScrollView matches the height of the Fragment so that contents of the ScrollView don't get hidden behind the Fragment)
You could also do this using LinearLayout as the parent element with an attribute of android:orientation="vertical", and the ScrollView and Fragment each getting an appropriate layout_weight attribute, but that's not as clean imho, so I'll leave it to you if you'd prefer to do that.
<ScrollView>
<RelativeLayout>
//main content
</RelativeLayout>
<FrameLayout android:alignParentBottom="true"/> load fragment here dynamically(or not)
</ScrollView>
This worked for me. Check this question out aswell

Textview is not setting Relative layout in android

i am facing Problem In Relative layout
i set a textview below the description
but text taking topmargin from description
textview is PDFlink spacings are comming between pdf link and descrption
what is the problem
i m also sending you my layout file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00ffffff"
android:orientation="horizontal" >
<RelativeLayout
android:id="#+id/info_l1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="3dp"
android:paddingTop="1dp"
android:paddingBottom="1dp"
android:paddingRight="3dp"
>
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="sunilsunilsunil"
android:textStyle="bold"
android:visibility="gone"
android:textColor="#313131"
android:textSize="13sp" />
<TextView
android:id="#+id/aprrovedate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/title"
android:layout_marginTop="10dp"
android:textSize="12sp"
android:textStyle="bold"
android:textColor="#313131"
android:layout_below="#+id/backreturn"
android:text="TextView" />
<com.customviews.Fonttextview
android:id="#+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/aprrovedate"
android:layout_below="#+id/aprrovedate"
android:text="TextView"
android:textSize="13sp" />
<com.customviews.Underlintextview
android:id="#+id/pdflink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/description"
android:layout_below="#+id/description"
android:text="scarica PDF"
android:textSize="13sp"
android:textColor="#FF2A2A" />
<com.customviews.Underlintextview
android:id="#+id/backreturn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/title"
android:layout_below="#+id/title"
android:textColor="#FF2A2A"
android:textSize="12sp"
android:visibility="gone"
android:text="TextView" />
</RelativeLayout>

Create a listview with sides like older email android app

I want to create a listview like older gmail app. See the screenshot:
I tried putting an empty view like this:
<TextView
android:id="#+id/color_highlight"
android:layout_width="5dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#ff0000"
android:minHeight="48dp" />
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
android:layout_toLeftOf="#id/color_highlight"
android:text="Mudit Agarwal"
android:textStyle="bold"
android:textColor="#242424"
android:textIsSelectable="false"
android:textSize="22sp" />
<TextView
android:id="#+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#id/name"
android:layout_below="#id/name"
android:text="9933445566"
android:textColor="#777777"
android:textIsSelectable="false"
android:layout_marginBottom="10dp"
android:textSize="15sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:padding="3dp"
android:src="#drawable/contact" />
but this is not taking full height of the view. Please suggest.
What I changed is
android:layout_alignBottom="#+id/number"
to your color_highlight TextView. and instead of margin, I put padding like below in number TextView.
android:paddingBottom="20dp"
just put following layout code.
<?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="wrap_content" >
<TextView
android:id="#+id/color_highlight"
android:layout_width="5dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_alignBottom="#+id/number"
android:background="#ff0000"
android:minHeight="48dp" />
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
android:layout_toLeftOf="#id/color_highlight"
android:text="Mudit Agarwal"
android:textColor="#242424"
android:textIsSelectable="false"
android:textSize="22sp"
android:textStyle="bold" />
<TextView
android:id="#+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#id/name"
android:layout_below="#id/name"
android:paddingBottom="20dp"
android:text="9933445566"
android:textColor="#777777"
android:textIsSelectable="false"
android:textSize="15sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:padding="3dp"
android:src="#drawable/contact" />
</RelativeLayout>
I'm not sure but you can try putting android:layout_height="0dip" instead of android:layout_height="match_parent".

I can't get the button to the bottom of the layout

I'm trying to get the button to the bottom the layout, and it just won't work...
The button is displaying it self on the image that should be above it.
Here is the xml code:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:layout_gravity="center"
>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="28dp"
android:layout_marginTop="32dp" />
<TextView
android:id="#+id/txtAppName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/imageView1"
android:layout_marginLeft="22dp"
android:layout_toRightOf="#+id/imageView1"
android:text=""
android:textSize="36px"
android:textStyle="bold" />
<TextView
android:id="#+id/txtAppAuthor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/txtAppName"
android:layout_below="#+id/txtAppName"
android:layout_marginTop="5px"
android:text=""
android:textSize="24px"
android:textStyle="normal" />
<TextView
android:id="#+id/txtAppDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/imageView1"
android:layout_below="#+id/imageView1"
android:layout_marginTop="20dp"
android:maxHeight="350px"
android:text=""
android:width="600px"
android:maxLines="10"
android:scrollbars = "vertical"
/>
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/txtAppDesc"
android:layout_below="#+id/txtAppDesc"
android:layout_marginTop="30dp" />
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/imageView2"
android:layout_toRightOf="#+id/imageView2" />
<ImageView
android:id="#+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/imageView3"
android:layout_toRightOf="#+id/imageView3"
android:visibility="visible" />
<Button
android:id="#+id/btnInstall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_alignBottom="#+id/imageview4"
android:text="Download & Install" />
</RelativeLayout>
</ScrollView>
And the result is:
Thanx upfront.
You used android:layout_alignBottom="#+id/imageview4"
This means you align the bottom of your button with the bottom of your image.
You have to use android:layout_below="#+id/imageview4"
EDIT: I don't say this is the best solution, because of multiple layouts (for optimisation...) but this should work:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:layout_gravity="center"
>
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="28dp"
android:layout_marginTop="32dp"/>
<TextView
android:id="#+id/txtAppName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/imageView1"
android:layout_marginLeft="22dp"
android:layout_toRightOf="#+id/imageView1"
android:text=""
android:textSize="36px"
android:textStyle="bold"/>
<TextView
android:id="#+id/txtAppAuthor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/txtAppName"
android:layout_below="#+id/txtAppName"
android:layout_marginTop="5px"
android:text=""
android:textSize="24px"
android:textStyle="normal"/>
<TextView
android:id="#+id/txtAppDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/imageView1"
android:layout_below="#+id/imageView1"
android:layout_marginTop="20dp"
android:maxHeight="350px"
android:text=""
android:width="600px"
android:maxLines="10"
android:scrollbars="vertical"
/>
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/txtAppDesc"
android:layout_below="#+id/txtAppDesc"
android:layout_marginTop="30dp"/>
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/imageView2"
android:layout_toRightOf="#+id/imageView2"/>
<ImageView
android:id="#+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/imageView3"
android:layout_toRightOf="#+id/imageView3"
android:visibility="visible"/>
</RelativeLayout>
<Button
android:id="#+id/btnInstall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Download & Install"/>
</LinearLayout>
</ScrollView>
I added a linear layout in which I put the content, and the button.
Hope this will work.
Do you just want the image that the button is over to shrink in order to make room for it? If so, you need to put the Imageview that contains that image as the very last item in your relative layout. It's going to allocate space for everything but the image, and then give the remaining space to the image, which is why it needs to be last.
Also, I suggest giving your imageViews more informative names than "imageView#", since it's kind of difficult to tell which is which.
You might want to wrap you images in a HorizontalScrollView to maintain full height and width of all your images. I changed a lot of the ViewGroups' widths and heights to accommodate the HorizontalScrollView, finally I set the Button below the images:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fillViewport="true" >
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="28dp"
android:layout_marginTop="32dp" />
<TextView
android:id="#+id/txtAppName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/imageView1"
android:layout_marginLeft="22dp"
android:layout_toRightOf="#+id/imageView1"
android:text=""
android:textSize="36px"
android:textStyle="bold" />
<TextView
android:id="#+id/txtAppAuthor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/txtAppName"
android:layout_below="#+id/txtAppName"
android:layout_marginTop="5px"
android:text=""
android:textSize="24px"
android:textStyle="normal" />
<TextView
android:id="#+id/txtAppDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/imageView1"
android:layout_below="#+id/imageView1"
android:layout_marginTop="20dp"
android:maxHeight="350px"
android:maxLines="10"
android:scrollbars="vertical"
android:text=""
android:width="600px" />
<HorizontalScrollView
android:id="#+id/images"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/txtAppDesc"
android:layout_marginTop="30dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:id="#+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</HorizontalScrollView>
<Button
android:id="#+id/btnInstall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/images"
android:layout_centerHorizontal="true"
android:text="Download & Install" />
</RelativeLayout>
</ScrollView>
Understand that nesting a HorizontalScrollView inside a ScrollView (or vica versa) does not create a smooth scrolling effect in the x & y directions simultaneously. But you can create this effect as discussed here: Scrollview vertical and horizontal in android.

Categories

Resources