【问题标题】:Why is there a gap between image and top of screen in my android app?为什么我的 Android 应用程序中的图像和屏幕顶部之间存在间隙?
【发布时间】:2012-10-01 10:57:27
【问题描述】:

在我的 xml 文件中,我正在使用它。我的问题是,为什么在较小的屏幕上使用它时,屏幕顶部和图像之间会出现如此巨大的差距。但是在大屏幕上一切都很好。

编辑:我认为问题在于重量。有什么想法吗?

<LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

    <ImageView
        android:id="@+id/area"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp"
        android:layout_weight="1"
        android:src="@drawable/area_selector" 
        android:contentDescription="@string/app_name"/>

    <ImageView
        android:id="@+id/volume"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp"
        android:layout_weight="1"
        android:src="@drawable/volume_selector" 
        android:contentDescription="@string/app_name"/>

    </LinearLayout>

【问题讨论】:

  • 尝试将android:adjustViewBounds="true"添加到imageview标签中。
  • 完美运行!!非常感谢!
  • 请添加答案并验证它以关闭此问题。

标签: android xml imageview


【解决方案1】:

代表 Teovalds,评论的答案作为答案: 尝试将android:adjustViewBounds="true" 添加到 imageview 标签。

【讨论】:

    【解决方案2】:

    还可以删除添加的 magintop = 10 dp 以最小化间隙!

    【讨论】:

      猜你喜欢
      • 2018-03-22
      • 2015-05-20
      • 1970-01-01
      • 2016-01-08
      • 2015-08-12
      • 1970-01-01
      • 2017-10-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多