<?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.
Related
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.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:orientation=""
android:layout_marginTop="40dp" >
<LinearLayout
android:id="#+id/imagecontainlayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="5"
android:background="#drawable/round_bg"
android:orientation="horizontal"
android:padding="10dp" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".75"
android:singleLine="true"
android:text="Status:"
android:textColor="#0060a4"
android:textSize="15dp" />
<TextView
android:id="#+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3.5"
android:textColor="#0060a4"
android:textSize="15dp" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="20dip"
android:layout_height="20dip"
android:layout_weight=".75" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="295dp"
android:layout_height="44dp"
android:background="#drawable/round_bg"
android:orientation="horizontal"
android:padding="10dp" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".75"
android:singleLine="true"
android:text="Status:"
android:textColor="#0060a4"
android:textSize="15dp" />
<TextView
android:id="#+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3.5"
android:textColor="#0060a4"
android:textSize="15dp" />
</LinearLayout>
</LinearLayout>
Here is my Xml am trying to set imagecontainlayout linear layout to another linear layout containing another linear layout with some gap but i dont know where am doing mistake in my code my current screen is coming like this .
my current screen is coming like this while i want there first layout below another layout with some gap please help me where am doing mistake.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/round_bg"
android:orientation="horizontal"
android:padding="10dp" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".75"
android:singleLine="true"
android:text="Step:"
android:textColor="#0060a4"
android:textSize="15dp" />
<TextView
android:id="#+id/step"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3.5"
android:textColor="#0060a4"
android:textSize="15dp" />
</LinearLayout>
</LinearLayout>
use this code it will Help u .
<?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/linearLayout2"
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/linearLayout3"
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>
This is how the screen looks, can anyone tell me how can i achieve this layout. i have come up with the layout, but it seems it does not fit for all screens.
Make the LinearLayout width fill_parent to use the entire width of the screen.
Then for each TextView, set the layout_width to 0dp, and set layout_weight to the proportion of the screen you want that view to have.
In the padding, specify the minimum amount you want between the different cells.
For example, if you want the text to occupy double the space of the numbers, use the following code:
<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="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="5dip"
android:padding="1dip" >
<TextView
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:text="Total Pregnancies"
android:textColor="#000000" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:text="10"
android:textColor="#000000" />
<TextView
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:text="Full Term"
android:textColor="#000000" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:text="11"
android:textColor="#000000" />
<TextView
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:text="Premature"
android:textColor="#000000" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:text="12"
android:textColor="#000000" />
</LinearLayout>
</RelativeLayout>
Use TableLayout
Here is an example
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" />
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...