Relative Layout's layout and layout1 are used to display adds, top add is working perfectly but bottom add sometimes displayed at the bottom and sometime its displayed between the center and the bottom of the screen, I don't know what's wrong
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#drawable/zbackground" >
<RelativeLayout
android:id="#+id/layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true">
</RelativeLayout>
<RelativeLayout
android:id="#+id/layout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
</RelativeLayout>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_above="#+id/textView2"
android:layout_marginTop="10dip"
android:text="#string/about_text1"
android:textStyle="bold"
android:textColor="#ffffffff"
android:textSize="20dip" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_above="#+id/textView3"
android:textStyle="bold"
android:textColor="#ffffffff"
android:textSize="20dip" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textStyle="bold"
android:textColor="#ffffffff"
android:textSize="20dip" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="#+id/textView3"
android:textStyle="bold"
android:textColor="#ffffffff"
android:textSize="20dip" />
</RelativeLayout>
Try putting
<RelativeLayout
android:id="#+id/layout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
</RelativeLayout>
after
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_above="#+id/textView2"
android:layout_marginTop="10dip"
android:text="#string/about_text1"
android:textStyle="bold"
android:textColor="#ffffffff"
android:textSize="20dip" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_above="#+id/textView3"
android:textStyle="bold"
android:textColor="#ffffffff"
android:textSize="20dip" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textStyle="bold"
android:textColor="#ffffffff"
android:textSize="20dip" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="#+id/textView3"
android:textStyle="bold"
android:textColor="#ffffffff"
android:textSize="20dip" />
Related
Hi I have a problem with centering TextView in ScrollView. I want to center my TextViews with ids hajs, textView01, textView02 vertically in order to be in the center of height of imageViews. It's strange because in the Android Studio design I see everything right, but when I try on device I get these TextViews in the top of the TextView.
<?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">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/scrollView"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:fillViewport="true">
<RelativeLayout
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal" >
<TextView
android:id="#+id/hajs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/imageView1"
android:layout_alignParentLeft="true"
android:layout_alignTop="#+id/imageView1"
android:layout_centerInParent="true"
android:layout_toLeftOf="#+id/imageView1"
android:background="#41BF17"
android:gravity="center_vertical|center|center_horizontal"
android:text="0"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFF"
android:textSize="70sp" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:background="#41BF17"
android:gravity="center"
android:text="#string/zaoszczedziles"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFF"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/textView2"
android:adjustViewBounds="true"
android:background="#41BF17"
android:maxWidth="100dp"
android:src="#drawable/moneybag" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/hajs"
android:background="#41BF17"
android:gravity="center"
android:text="#string/dni_bez_papierosow"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFF"
android:textStyle="bold" />
<ImageView
android:id="#+id/ImageView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/textView3"
android:adjustViewBounds="true"
android:background="#41BF17"
android:maxWidth="100dp"
android:src="#drawable/calendar" />
<TextView
android:id="#+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/ImageView01"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/hajs"
android:layout_alignTop="#+id/ImageView01"
android:layout_centerInParent="true"
android:background="#41BF17"
android:gravity="center"
android:text="0"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFF"
android:textSize="70sp" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
I've a linear layout with inside 3 different relative layout.I want to divide in 3 equals parts this root linear layout.I've set the weight sum to 3 in linear layout and set to 0 the width for each relative.But when i hide one of this relative,the other two are not centered as expected.This is the xml code `
<RelativeLayout
android:id="#+id/OffertaBassa"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="visible" >
<TextView
android:id="#+id/offertaPiuBassa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:layout_gravity="top|center"
android:layout_margin="5dp"
android:gravity="center"
android:text="#string/scheda_dettaglio_richiesta_offerta_migliore"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/macingo_gabriele_testo"
android:textSize="12dp"
android:visibility="visible" />
<TextView
android:id="#+id/PrezzoBasso"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/offertaPiuBassa"
android:layout_centerInParent="true"
android:layout_gravity="center_vertical|center_horizontal|top"
android:gravity="center"
android:text="€"
android:textColor="#color/macingo_drawer_listItem_selected"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/ivaEsclusaLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/PrezzoBasso"
android:layout_centerInParent="true"
android:layout_gravity="center_vertical|center_horizontal|top"
android:text="IVA esclusa"
android:textColor="#color/macingo_card_text_light"
android:textSize="10sp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/NumeroPreventivi"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="visible" >
<TextView
android:id="#+id/preventiviRicevuti"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:layout_gravity="top|center"
android:layout_margin="5dp"
android:gravity="center"
android:text="#string/scheda_dettaglio_richiesta_preventivi_ricevuti"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/macingo_gabriele_testo"
android:textSize="12dp"
android:visibility="visible" />
<TextView
android:id="#+id/numeroPreventivi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/preventiviRicevuti"
android:layout_centerInParent="true"
android:layout_gravity="center_vertical|center_horizontal|top"
android:text="N°"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/macingo_card_text"
android:textSize="18sp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/prezzoriferimento"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="visible" >
<TextView
android:id="#+id/prezzoRiferimento"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:layout_gravity="top|center"
android:layout_margin="5dp"
android:gravity="center"
android:text="#string/scheda_dettaglio_richiesta_prezzo_riferimento"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/macingo_gabriele_testo"
android:textSize="12sp"
android:visibility="visible" />
<TextView
android:id="#+id/prezzoDiriferimento"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/prezzoRiferimento"
android:layout_centerInParent="true"
android:layout_gravity="center_vertical|center_horizontal|top"
android:text="€"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/macingo_card_text"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/TextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/prezzoDiriferimento"
android:layout_centerInParent="true"
android:layout_gravity="center_vertical|center_horizontal|top"
android:text="IVA esclusa"
android:textColor="#color/macingo_card_text_light"
android:textSize="10sp"
android:textStyle="bold" />
</RelativeLayout>
</LinearLayout>`
How can i solve this situation?I've tried to set gravity but with no result.
Thanks
You can do something like this.
Please go through this Code.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:weightSum="3" >
<RelativeLayout
android:id="#+id/OffertaBassa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="visible" >
<TextView
android:id="#+id/offertaPiuBassa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:layout_gravity="top|center"
android:layout_margin="5dp"
android:gravity="center"
android:text="scheda_dettaglio_richiesta_offerta_migliore"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textSize="12dp"
android:visibility="visible" />
<TextView
android:id="#+id/PrezzoBasso"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/offertaPiuBassa"
android:layout_centerInParent="true"
android:layout_gravity="center_vertical|center_horizontal|top"
android:gravity="center"
android:text="€"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/ivaEsclusaLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/PrezzoBasso"
android:layout_centerInParent="true"
android:layout_gravity="center_vertical|center_horizontal|top"
android:text="IVA esclusa"
android:textColor="#000000"
android:textSize="10sp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/NumeroPreventivi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="visible" >
<TextView
android:id="#+id/preventiviRicevuti"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:layout_gravity="top|center"
android:layout_margin="5dp"
android:gravity="center"
android:text="scheda_dettaglio_richiesta_preventivi_ricevuti"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textSize="12dp"
android:visibility="visible" />
<TextView
android:id="#+id/numeroPreventivi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/preventiviRicevuti"
android:layout_centerInParent="true"
android:layout_gravity="center_vertical|center_horizontal|top"
android:text="N°"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/prezzoriferimento"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="visible" >
<TextView
android:id="#+id/prezzoRiferimento"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:layout_gravity="top|center"
android:layout_margin="5dp"
android:gravity="center"
android:text="scheda_dettaglio_richiesta_prezzo_riferimento"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textSize="12sp"
android:visibility="visible" />
<TextView
android:id="#+id/prezzoDiriferimento"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/prezzoRiferimento"
android:layout_centerInParent="true"
android:layout_gravity="center_vertical|center_horizontal|top"
android:text="€"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/TextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/prezzoDiriferimento"
android:layout_centerInParent="true"
android:layout_gravity="center_vertical|center_horizontal|top"
android:text="IVA esclusa"
android:textColor="#000000"
android:textSize="10sp"
android:textStyle="bold" />
</RelativeLayout>
</LinearLayout>
You have to visibility gone of Relative layout.
NumeroPreventivi.setVisibility(View.GONE);
have you visibility gone or invisible of Relative Layout?because if you doing visibility gone of layout then its work perfectly and if you are doing visibility invisible then this layout existence true. i mean this layout take area of layout.
at run time you have to change weight sum of layouts.
I'm working with the Google Maps API v2, and I overrided getInfoContents() from InfoWindowAdapter for having a customized InfoWindow. Inside getInfoContents()I inflate an xml containing an ImageView, and three TextViews.
My problem comes when the text that is set inside the snippet is larger than the view, then the count TV it's set outside the view. This is illustrated above with some screenshots.
Here my xml layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/categoryIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignBottom="#+id/count"
android:src="#drawable/ic_launcher"/>
<LinearLayout
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_toRightOf="#+id/categoryIcon"
android:layout_centerVertical="true"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
android:textStyle="bold" />
<TextView
android:id="#+id/snippet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Snippet" />
</LinearLayout>
<TextView
android:id="#+id/count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#111177"
android:text="0"
android:textSize="20sp"
android:padding="10dp"
android:textColor="#FFF"
android:layout_toRightOf="#+id/text"
android:singleLine="true" />
</RelativeLayout>
How can I change this layout for getting the count TextView inside of the screen, and the snippet in multiline?
I want to always show the count TextView.
UPDATE:
Finally with the answer of Simon Marquis I realized a way to accomplish this. Here the new code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/categoryIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignBottom="#+id/text"
android:src="#drawable/ic_launcher"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/text"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_toRightOf="#+id/categoryIcon">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
android:textStyle="bold" />
<TextView
android:id="#+id/snippet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Snippeta" />
</LinearLayout>
<TextView
android:id="#+id/count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#111177"
android:text="0"
android:textSize="20sp"
android:padding="10dp"
android:textColor="#FFF"
android:singleLine="true" />
</LinearLayout>
</RelativeLayout>
You should add this to the LinearLayout:
android:layout_width="0dp"
android:layout_weight="1"
The new layout file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/categoryIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignBottom="#+id/count"
android:src="#drawable/ic_launcher"/>
<LinearLayout
android:id="#+id/text"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_toRightOf="#+id/categoryIcon"
android:layout_centerVertical="true"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
android:textStyle="bold" />
<TextView
android:id="#+id/snippet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Snippet" />
</LinearLayout>
<TextView
android:id="#+id/count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#111177"
android:text="0"
android:textSize="20sp"
android:padding="10dp"
android:textColor="#FFF"
android:layout_toRightOf="#+id/text"
android:singleLine="true" />
</RelativeLayout>
One solution if you want that the count TextView always appears at right is the following:
Put the count Text View before the LinearLayout and add
android:layout_alignParentRight="true"
And add android:layout_toLeftOf="#id/count" in the Linear Layout
<TextView
android:id="#+id/count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#00F"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#id/count"
android:orientation="vertical" >
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/snippet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dip" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="5dip"
android:padding="1dip" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="20dp"
android:text="Total Pregnancies"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="30dp"
android:text="10"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="160dp"
android:text="Full Term"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="75dp"
android:text="11"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="190dp"
android:text="Premature"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="30dp"
android:text="12"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/linearLayout1"
android:layout_below="#+id/linearLayout1"
android:layout_marginTop="35dp"
android:padding="1dip" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="20dp"
android:text="Multiples"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="85dp"
android:text="16"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="160dp"
android:text="Living"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="95dp"
android:text="17"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/linearLayout1"
android:layout_centerVertical="true"
android:padding="1dip" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="20dp"
android:text="Ab Included"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="70dp"
android:text="13"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="160dp"
android:text="Ab Spontaneous"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="30dp"
android:text="14"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="190dp"
android:text="Ectopics"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="35dp"
android:text="15"
android:textColor="#000000" />
</LinearLayout>
</RelativeLayout>
Can anyone tell me whats wrong with this layout as it seems not working in portrait mode, but perfectly fits the screen when it comes to landscape. I have attached the screen shot of what i am trying to do, the above is a lists which is added to a ListView.
Update:
The View gets gets cluttered when in portrait mode.
There are some problems with what you've written:
You assume that the width would suffice no matter what is the screen . You might want to add a horizontalScrollView or use a different layout.
You have the same id for each of the layouts.
Why do you have android:orientation="vertical" for your RelativeLayout?
All the LinearLayouts have the same id linearLayout1. I think you should give different ids to different views.
I'm using this layout in one of my applications. I don't know why it is getting distorted. The main issue is that in all the three LinearLayout blocks, only the first TextView is displayed on the screen and in place of the TextViews following that, a big blank space is displayed.
The snapshot of the image being displayed is Snapshot...
Layout.xml
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5sp" >
<LinearLayout
android:id="#+id/ll_images"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:orientation="vertical"
android:padding="10sp" >
<ImageView
android:id="#+id/certification_image"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:contentDescription="#string/details_image"
android:visibility="gone" />
<ImageView
android:id="#+id/image_details_page"
android:layout_width="100sp"
android:layout_height="100sp"
android:contentDescription="#string/details_image" />
</LinearLayout>
<TextView
android:id="#+id/details_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#id/ll_images"
android:padding="10sp"
android:textColor="#040404"
android:textSize="25sp"
android:textStyle="bold"
android:typeface="sans" />
<TextView
android:id="#+id/details_tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/details_name"
android:layout_toLeftOf="#id/ll_images"
android:paddingLeft="5sp"
android:textColor="#343434"
android:textSize="15sp"
android:typeface="sans" />
<LinearLayout
android:id="#+id/ll_facts"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/ll_images">
<TextView
android:id="#+id/tv_facts"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/gradient_bg"
android:padding="10sp"
android:text="Facts"
android:textColor="#android:color/darker_gray"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/details_tv2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5sp"
android:textSize="15sp"
android:text="#string/test" />
<TextView
android:id="#+id/details_tv3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5sp"
android:text="#string/test"
android:textSize="15sp" />
<TextView
android:id="#+id/details_tv4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5sp"
android:text="#string/test"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_foundation"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/ll_facts">
<TextView
android:id="#+id/tv_foundation"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/gradient_bg"
android:padding="10sp"
android:text="Foundation Statement"
android:textColor="#android:color/darker_gray"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/details_tv5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5sp"
android:textColor="#343434"
android:text="#string/test"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_overview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/ll_foundation">
<TextView
android:id="#+id/tv_overview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/gradient_bg"
android:padding="10sp"
android:text="Overview"
android:textColor="#android:color/darker_gray"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/details_tv6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/test"
android:paddingLeft="5sp"
android:textColor="#343434"
android:textSize="15sp" />
</LinearLayout>
<Button
android:id="#+id/btnViewScorecard"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/ll_overview"
android:layout_margin="5sp"
android:background="#drawable/search_button"
android:paddingLeft="10sp"
android:text="#string/ViewScorecard"
android:textColor="#FFFFFF"
android:typeface="sans"
android:visibility="gone"/>
</RelativeLayout>
Any help would be really appreciated. Thanks in advance!!!
You forget about
xmlns:android="http://schemas.android.com/apk/res/android"
Just change
<RelativeLayout
to
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
Finally I have figured it out... All I had to do was I had to add the following line to my LinearLayout.
android:orientation="vertical"
Thanks all for the help...