Android-无法将textview置于framelayout下方 [英] Android - Can't make the textview below the framelayout

查看:79
本文介绍了Android-无法将textview置于framelayout下方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在LinearLayout中有一个TextView和FrameLayout. 我无法将TextView放在框架布局下方,而是一直停留在顶部.

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

这是我的代码:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="bottom"
        android:text="TextView" />

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

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

        <ImageButton
            android: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>

</LinearLayout>

推荐答案

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="0dp" 
        android:layout_weight="1">

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

        <ImageButton
            android: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>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="bottom"
        android:text="TextView" />

</LinearLayout>

请注意FrameLayoutlayout_weightlayout_height.如果您将高度保持在match_parent位置,它将适合整个屏幕,将TextView 紧靠在屏幕末端之后.

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 TextView right after the end of the screen.

LinearLayout s中检查有关 layout_weight的链接.

Check this link about layout_weight in LinearLayouts.

这篇关于Android-无法将textview置于framelayout下方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆