【问题标题】:Frame Layout Different on different screen sizesFrame Layout 不同屏幕尺寸不同
【发布时间】:2013-01-20 16:28:18
【问题描述】:

我遇到了一个大问题。相同的 .xml 在较大的屏幕上可以正常工作,但在较小的屏幕上则不行。该问题出现在模拟器和真机上。这是我的 .XML。

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<LinearLayout
    android:id="@+id/linearview"
    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:layout_marginLeft="50dp"
    android:layout_marginTop="100dp"
    android:background="#FFFFFF"
    android:visibility="visible"
    android:text="CLOSED"
    android:textColor="#FF0000"
    android:textSize="12dp"
    android:textStyle="bold" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="123sp"
    android:layout_marginTop="100dp"
    android:background="#FFFFFF"
    android:visibility="visible"
    android:text="CLOSED"
    android:textColor="#FF0000"
    android:textSize="12dp"
    android:textStyle="bold" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="193dp"
    android:layout_marginTop="200dp"
    android:background="#FFFFFF"
    android:visibility="visible"
    android:text="CLOSED"
    android:textColor="#FF0000"
    android:textSize="12dp"
    android:textStyle="bold" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="263dp"
    android:layout_marginTop="200dp"
    android:background="#FFFFFF"
    android:visibility="visible"
    android:text="CLOSED"
    android:textColor="#FF0000"
    android:textSize="12dp"
    android:textStyle="bold" />

</FrameLayout>

这里是不同尺寸屏幕的屏幕截图。基本上,我编写了一个代码,用“封闭”文本视图覆盖图表上的“0”。在较大的屏幕上工作正常,但在较小的屏幕上,所有的 TextViews 都聚集在角落里。我已经尝试过 layout-small、layout 和 layout-large .xmls。似乎没有任何效果。

【问题讨论】:

    标签: android layout android-framelayout


    【解决方案1】:

    想通了!!

    我必须先在 TextVeiws 上设置布局重力,然后它才开始工作。奇怪的是,它在没有指定重力属性的情况下在更大的屏幕上工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-05-23
      • 2015-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多