Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/224.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 以横向方向启动时,TextView行边界值不匹配_Android_Android Layout_Screen Orientation - Fatal编程技术网

Android 以横向方向启动时,TextView行边界值不匹配

Android 以横向方向启动时,TextView行边界值不匹配,android,android-layout,screen-orientation,Android,Android Layout,Screen Orientation,方向改变后,我的文本视图有一个令人困惑的问题: <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView

方向改变后,我的文本视图有一个令人困惑的问题:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="vertical"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent">

<TextView
        android:text="Simple"
        android:layout_width="fill_parent"
        android:layout_height="200dp"
        android:background="@drawable/my_color_drawable"
        android:id="@+id/text1"
        android:layout_gravity="center"/><\FrameLayout>

当我以横向模式启动应用程序时,方法
getLineBounds(1,tmpRect)
结果:

  • tmpRect.top=69
然后我将手机方向更改为纵向,结果如下:

  • tmpRect.top=76
Hovewer在更改回横向后,结果设置为74(之前为69),从现在起两个结果都不会更改

在纵向模式下启动应用程序时,结果分别为76和74

我真的很好奇,为什么在景观中开始时,数字是不同的,我会感谢任何帮助

信息:我的活动设置了android:screenOrientation=“sensor”

编辑:似乎只有在使用android>4时才会出现问题


谢谢。

使用横向和纵向时需要两种布局,否则值会更改。它根据创建布局的方向设置为默认值。 如果只需要在一种模式下工作,则设置为

android:screenOrientation="portrait"


我必须在两种模式下工作,只有一种布局(没有陆地端口差异),我的问题是,文本边界只有在我启动应用程序时无效,而不是在整个时间内无效,这就是我问题的原因(陆地端口工作不好[在第一个陆地文本有无效边界,端口好,第二个陆地也好]但当应用程序在港口启动时(景观一直运行良好)
android:screenOrientation="landscape"