【问题标题】:Android - Layout question - Textviews top center and bottom centerAndroid - 布局问题 - Textviews 顶部中心和底部中心
【发布时间】:2010-07-29 22:10:46
【问题描述】:

我有一个布局问题。

假设我的屏幕底部出现了一个 RelativeLayout。在此,我想添加 2 个文本视图,在中心,一个在顶部中心,一个在底部中心。

|--------------------------|
|          Text1           |
|          Text2           |
|--------------------------|

类似的东西:-)

【问题讨论】:

  • 你的问题有误导性。你已经放了“图像”,我首先知道你需要在屏幕的“中心水平”处有 2 个文本视图......相反,你应该放图像其中包含顶部的一个文本和底部的一个文本
  • @Paresh - 你能详细说明一下吗?我似乎很清楚他的要求,但不是你想说的……
  • @Shouvik...他按照他的要求放置了未显示的图像“一个文本视图在顶部中心,一个在底部中心”..我希望你明白了

标签: android layout center textview


【解决方案1】:

这对你有什么好处:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:gravity="center_horizontal">
    <TextView android:id="@+id/text1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Text 1"/>   
    <TextView android:id="@+id/text2"
              android:layout_below="@id/text1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Text 2"/>
</RelativeLayout>

【讨论】:

  • 两个文本视图都出现在“中心水平”...他问“一个在顶部中心,一个在底部中心”
  • 如果他想要它就像他在问题中画的文字图片一样,这将起作用......但他已经消失了,所以我们永远不会知道:)
猜你喜欢
  • 2019-03-30
  • 2015-08-11
  • 1970-01-01
  • 1970-01-01
  • 2017-02-16
  • 2015-04-24
  • 1970-01-01
  • 2022-01-15
  • 2022-11-02
相关资源
最近更新 更多