Andy Coarse
Andy Coarse

Reputation: 25

Android XML Layout overlay

I would like to consult a xml layout problem. I have a main activity, which is a TabActivity and it is filled (the tabs are) by another activity, which is a ListActivity. On the scrren together with main TabActivity I want to show a gray strip with button(s) on the bottom of the page. The problem is that the last item of the listview is hidden by the strip. So what I need is, that listview should has a border at the same point where the border of button strip begins. It is demonstrated by the picture here:

http://postimage.org/image/h8yx7jxlj/

I have already tried to change layout_height parameter of several layouts to wrap_content, but it hasn´t helped...

P. S. Is there a way how to change font size of the tab header IN XML LAYOUT FILE?

This is my xml layout of main activity:

<?xml version="1.0" encoding="utf-8"?>

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@android:id/tabhost"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent">
<LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp">

    <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />


    <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp" />


</LinearLayout>

<LinearLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:gravity="center"
        android:background="#666666">

    <Button android:id="@+id/settins_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="1sp"
            android:text="volba zdrojů"
            android:enabled="false" />

</LinearLayout>

This is xml layout code of the activity which is inserted into tabcontrol as a content of the tab. (then inserted into FrameLayout of the tabcontrol):

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="vertical"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent">

<ListView
        android:id="@+id/android:list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>


<TextView
        android:id="@+id/android:empty"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="center_vertical|center_horizontal"
        android:text="@string/main_no_items"/>

</LinearLayout>

Thank you very much!

Upvotes: 0

Views: 4177

Answers (1)

Blehi
Blehi

Reputation: 2020

Please use RelativeLayout instead of LinearLayout. Please see the attached code which does exactly what you want.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#FFFFFF" >

    <TextView
        android:id="@+id/text"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/button"
        android:layout_alignParentTop="true"
        android:gravity="center_horizontal"
        android:text="some text goes here"
        android:textColor="#1E1E1E"
        android:textSize="25sp" />

    <LinearLayout
        android:id="@+id/button"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/btn_send"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:layout_weight="50"
            android:onClick="handleSendReport"
            android:text="@string/button_send" />
    </LinearLayout>

</RelativeLayout>

Upvotes: 1

Related Questions