【问题标题】:Linear Layout Adjustment is Not Happening线性布局调整未发生
【发布时间】:2013-12-28 23:38:45
【问题描述】:

我正在创建一个应用程序。我遇到了一个棘手的问题。我已经在所有三星设备、htc 设备、索尼设备、平板电脑上运行了我的应用程序。但是在其中的一些设备中,布局并没有达到应有的效果。

我在这里发布一个屏幕截图。

现在您可以看到,在地球图像之后,第二个图像之后出现了一个间隙。在地球图像中,我使用画廊视图,而在星座图像中,我使用网格视图。现在这个间隙完全没有出现我测试的设备,但在少数设备中,这种差距即将到来。为什么会这样?

我正在发布布局文件。

      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical"    
android:weightSum="2"

 >


<ListView
    android:id="@+id/mylistcat"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1" >

</ListView>

<com.origamilabs.library.views.StaggeredGridView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:staggered="http://schemas.android.com/apk/res-auto"
    android:id="@+id/gridviewrashisuggestions"
    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:layout_gravity="bottom"
    android:layout_marginLeft="0.5dp"
    android:layout_marginRight="0.5dp"
    android:stretchMode="columnWidth"
    staggered:drawSelectorOnTop="false"
    staggered:numColumns="1" />

现在我的列表视图有一个列表 row.xml 和网格视图只有一个图像。我怎样才能减少差距?从哪里来?我使用了布局权重= 2,我将它设置为 listview=1 和 gridview=1 那么差距是怎么来的?

请帮助...这是一个索尼 experia 模型的问题。它的高度更大但宽度更小。这种特殊的布局在物理设备中几乎可以调整高度和宽度的情况下运行良好。比如三星和 htc。

【问题讨论】:

  • 没人帮忙吗? :(

标签: android android-linearlayout adjustment


【解决方案1】:

你想达到什么目标?设置权重同样意味着 LinearLayout 中两个元素的高度相同。为了更好地理解差距的来源,请尝试为各个元素设置不同的背景颜色。

星座图看起来被裁剪了,因为上视图占据了屏幕的一半,没有足够的空间。

【讨论】:

  • 星座图完美呈现。它是可滚动的。当我发布屏幕截图时,我将其向上滚动,以便 SO 成员可以看到。我不需要那个间隙。
  • 差距不知从何而来............我无法控制那个差距。根据程序或布局设计,差距不应该存在。差距不会到来到每个设备。它只出现在少数设备中。 :(
  • 如果我将布局权重 = 2 设置为星座视图,则没有间隙。但在较小的屏幕中,将布局权重 = 2 设置为星座视图会使画廊视图变小并滚动。 !!
  • 你有没有试过设置背景颜色来查看,哪个视图导致了差距?
猜你喜欢
  • 2017-07-18
  • 1970-01-01
  • 2017-04-15
  • 2015-04-15
  • 2021-11-10
  • 2016-11-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多