aspose file tools*
The moose likes Android and the fly likes FrameLayout overlaps TextView Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "FrameLayout overlaps TextView" Watch "FrameLayout overlaps TextView" New topic
Author

FrameLayout overlaps TextView

Lou Cabron
Greenhorn

Joined: Aug 29, 2012
Posts: 3
I'm using a RelativeLayout for a very simple app which consists of a textView at the top and a FrameLayout at the bottom. But the FrameLayout keeps overlapping the TextView on small-screen devices (like a cellphone). Here's some of the things I've tried that *haven't* worked to resolve the problem. (I tried Weight="1", but it's a relativeLayout, so Eclipse gives an error message. And I tried android:layout_below="@id/theText" but the contents of the FrameLayout then decide to vertically align themselves at the *top* of the FrameLayout...)


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:id="@+id/myLayout"
android:clickable="true"
androidnClick="myMethod"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"
android:id="@+id/theText"
android:textSize="34sp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:gravity="center"
android:shadowColor="@color/white"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"

/>


<FrameLayout
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
></FrameLayout>
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

The key is, you layout the frame's alignment to the bottom of the screen and you make it below the text area.

Now the Frame will always take the space from just below the text to the bottom of the screen. The problem is that your content is probably bigger than that, which is why your bottom-aligned frame overlapped the text to begin with. Using the above mechanism will essentially ignore the frame's 'wrap_content' height to make it align appropriately. So to get the content on small screens you will need to wrap the FrameLayout into a ScrollView.

This with an AnalogClock that makes the Frame not fit on small screens. See the result image below. (Note the area with the Clock should scroll but that isn't shown in the static image). Also note that I only have one thing inside my FrameLayout. If that is your case, I would replace the FrameLayout with the ScrollView instead of wrapping it in the ScrollView.



[Thumbnail for TextAndFrame with Clock.png]



Steve
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FrameLayout overlaps TextView