I have a problem with this layout and i cannot find out what is wrong. As you can see, there is a chronometer and a table inside a relative layout but the chronometer does not s
Try this...this will definitly solve your problem..
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/firstLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Chronometer
android:id="@+id/chrono"
android:textColor="#4169E1"
android:textSize="20sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="Chronometer"
/>
<TableLayout
android:id="@+id/parentLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/chrono"
>
</RelativeLayout>
First Stick Chronometer
to bottom android:layout_alignParentBottom="true"
then take TableLayout
on above of Chronometer
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/firstLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableLayout
android:id="@+id/parentLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/chrono" >
</TableLayout>
<Chronometer
android:id="@+id/chrono"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Chronometer"
android:textColor="#4169E1"
android:textSize="20sp" />
</RelativeLayout>
Your TableLayout
takes over all space (match_parent
) and draws over the Chronometer
. RelativeLayout
children are laid out in order they are declared. I don't know what you want exactly, but you can start by switching the order of the two in your layout so that the Chronometer
draws over the TableLayout
.
finally i got the way to display the chronometer. Thanks to everyone who tried to help me, the answers were really close to my solution which is:
<Chronometer
android:id="@+id/chrono"
android:textColor="#4169E1"
android:textSize="20sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Chronometer"
/>
<TableLayout
android:id="@+id/parentLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/chrono"
>