Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FrameLayout with the TextView on the bottom

I've got a FrameLayout like this. It contains two overlaying images:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/my_frame"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <ImageView 
        android:id="@+id/image_areas"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:scaleType="fitCenter"
        android:src="@drawable/image_mask"
        android:visibility="invisible"/>
    <ImageView
        android:id="@+id/image"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:scaleType="fitCenter"
        android:src="@drawable/walker"/>

</FrameLayout>

I want to add a TextView below this FrameLayout. Is it possible or does FrameLayout take all the space on the screen? Can I put my FrameLayout and TextView in a sort of LinearLayout?

Edit: The problem is that my TextView is not displayed when Im putting it in a LinearLayout or RelaiveLayout together with my FrameLayout.

like image 780
Denys Avatar asked Sep 27 '12 14:09

Denys


2 Answers

You can use a RelativeLayout to hold both your FrameLayout and TextView and in your FrameLayout use the android:layout_above atribute. Something like this:

<?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" >

<FrameLayout
    android:id="@+id/my_frame"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_above="@+id/TextViewId" >

    <ImageView
        android:id="@+id/image_areas"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scaleType="fitCenter"
        android:src="@android:drawable/alert_dark_frame"
        android:visibility="invisible" />

    <ImageView
        android:id="@+id/image"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scaleType="fitCenter"
        android:src="@android:drawable/btn_dialog" />
</FrameLayout>

<TextView
    android:id="@+id/TextViewId"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:text="TextView text" />

</RelativeLayout>
like image 191
Angelo Avatar answered Oct 25 '22 01:10

Angelo


<FrameLayout
    android:id="@+id/my_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:id="@+id/image_areas"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="fitCenter"
        android:src="@android:drawable/alert_dark_frame"
        android:visibility="invisible" />

    <ImageView
        android:id="@+id/image"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="fitCenter"
        android:src="@android:drawable/btn_dialog" />

    <TextView
        android:id="@+id/TextViewId"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:text="layout_gravity is the key here..."/>
</FrameLayout>
like image 23
worked Avatar answered Oct 24 '22 23:10

worked