Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

FrameLayout overlaps TextView

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"
android:onClick="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>
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
TextAndFrame-with-Clock.png
[Thumbnail for TextAndFrame-with-Clock.png]
Layout for Text on top of a frame with a clock in it
 
Well THAT's new! Comfort me, reliable tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic