【问题标题】:textview at the bottom of my layout not appearing我的布局底部的textview没有出现
【发布时间】:2011-10-05 09:48:44
【问题描述】:

好的,所以我有一个看起来像这样的布局:

LinearLayout
  TextView
  LinearLayout (Horizontal)
    TextView
    CustomImageView
  \LinearLayout
  TextView
\LinearLayout

但是我的底部文本视图被切断并且没有显示。我的内部 LinearLayout 和自定义视图都有其布局高度的 wrap_content 参数。我该怎么做才能确保底部的TextView会显示?

编辑:

这是底部textview的xml:

<TextView
android:id="@+id/Label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="title"
android:gravity="bottom"
android:textSize="16dp"/> 

滚动视图对我的项目也没有用,文本视图需要显示在同一屏幕上。

【问题讨论】:

  • 显示xml的一些简短的TextView的r属性
  • 尝试将滚动视图作为布局根。看看你是否可以查看你的 TextView..
  • 可以发截图吗?

标签: android android-layout


【解决方案1】:

一个技巧是用顶级的RelativeLayout而不是LinearLayout,这样就可以了。

另一个是在当前布局的顶层使用 ScrollView。

希望对你有帮助!

【讨论】:

    【解决方案2】:

    最好的方法是在顶层使用 RelativeLayout 而不是 LinearLayout ,然后您可以将 textView 放在底部,使用:android:alignParentBottom="true"

    【讨论】:

    • 这确实在底部显示了 textview,但它与上面的 imageview 重叠。如果我将 android:layout_below 添加到 TextView,那么我会遇到同样的问题,它会再次被切断屏幕。
    • 如果您将 ImageView 定义为 fill_parent ,它将与 textView 重叠,添加您的布局 Xml,我会为您修复它:)
    • 刚刚修好了。必须将底部 textview 放在 imageview 上方,并使用 android:layout_above 将 imageview 设置在其上方。不过感谢您的帮助!
    猜你喜欢
    • 2017-05-19
    • 1970-01-01
    • 2023-03-07
    • 1970-01-01
    • 1970-01-01
    • 2017-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多