Skip to content Skip to sidebar Skip to footer

Android - Can't Make The Textview Below The Framelayout

I have a TextView and FrameLayout inside a LinearLayout. I can't make the TextView below the framelayout, it keeps staying at the top. This is my code :

Solution 1:

<LinearLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" ><FrameLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"><FrameLayoutandroid:id="@+id/content_frame"android:layout_width="match_parent"android:layout_height="match_parent" /><ImageButtonandroid:id="@+id/btnGoToTop"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center|bottom"android:layout_margin="5dip"android:background="@drawable/buttongototop"android:padding="5dip"android:visibility="gone" /></FrameLayout><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:gravity="bottom"android:text="TextView" /></LinearLayout>

Pay attention to the FrameLayout's layout_weight and layout_height. If you kept the height with match_parent, it would fit the whole screen, positioning the TextViewright after the end of the screen.

Check this link about layout_weight in LinearLayouts.

Solution 2:

Try to invert the order of frameLayout and textView considering that you are in a LinearLayout;)

Solution 3:

Try This...

<LinearLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" ><FrameLayoutandroid:layout_width="match_parent"android:layout_height="match_parent" ><FrameLayoutandroid:id="@+id/content_frame"android:layout_width="match_parent"android:layout_height="match_parent" /><ImageButtonandroid:id="@+id/btnGoToTop"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center|bottom"android:layout_margin="5dip"android:background="@drawable/buttongototop"android:padding="5dip"android:visibility="gone" /></FrameLayout><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:gravity="bottom"android:text="TextView" /></LinearLayout>

Solution 4:

do the following changes to your TextView

<TextViewandroid:layout_width="wrap_content"android:layout_height="0dp"android:layout_weight="1"android:gravity="bottom"android:text="TextView" />

Let me know if it works.

Post a Comment for "Android - Can't Make The Textview Below The Framelayout"