【问题标题】:view over layout and equal height columns查看布局和等高列
【发布时间】:2013-08-15 09:01:01
【问题描述】:

我尝试了几件事并阅读了许多主题,但我没有找到任何解决我的问题的方法。

目前我有一个带有图片布局的 xml 文件。这就是它应该看起来像设计的样子,我使用 LinearLayouts 完成了它,并且效果很好。

问题是当我单击屏幕上的某个位置时,我希望从上到下添加突出显示的列。 我读到这应该使用RelativeLayout 来完成,但我尝试那样做,但我无法将其他元素排列成相同大小。

你知道这是怎么做到的吗?

这是我的 xml 的一部分:

<LinearLayout
    android:id="@+id/chart1Layout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="3dp"
    android:layout_weight="1"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_gravity="left"
        android:layout_marginRight="4dp"
        android:layout_weight="1"
        android:background="@color/color"
        android:gravity="bottom|center"
        android:maxLines="4"
        android:padding="3dp"
        android:text="@string/cap"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="@color/orange"
        android:textSize="30sp"
        android:textStyle="bold" />

    <com.some.chart
        android:id="@+id/result_widget_chartView1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:layout_weight="8"
        palette="grayscale"
        android:background="@color/dark_header"
        android:padding="0dp"
        android:paddingBottom="0dp"
        android:paddingLeft="10dp" />

</LinearLayout>

设计:http://i.stack.imgur.com/fkHvG.png

非常感谢。

【问题讨论】:

    标签: android xml layout android-linearlayout android-relativelayout


    【解决方案1】:

    看我的照片:

    如果这是你想要的?

    【讨论】:

    • 嗨,kevinhoo,对不起,我不明白你的想法。你能更详细一点吗?我的想法是添加一个具有半透明颜色的视图(列),在触摸的地方从上到下覆盖所有内容。我不知道,但我无法发布 xml,因为评论从中删除了一些文本。我有根 Vertical Linner 布局,所有其他组件都与上面的代码相同 - 在 Horizo​​ntal Linner 布局中。 image -link
    • 你有没有尝试过有一个相对的布局容器,并使半透明视图alignparentleft?
    • 是的,我尝试为容器设置相对布局,但如果我这样做了 - 我无法保持其他元素的高度相同。
    • 你的布局怎么样?你能把它们都贴出来吗?效果怎么样,能发个图吗?
    • 这是我的 xml 文件的图片 - xml file pic - 你可以查看其他图片在设备上的样子
    【解决方案2】:

    感谢您的回答。这不完全是我试图实现的目标,但是你给出了一些方向,我按照我的意愿做了。

    解决方案是将相对布局添加为根并保持一切原样,以保持设计。

    http://i.stack.imgur.com/j18Dw.png

    当我尝试用相对布局替换我的线性布局容器时,我做错了 - 我只需将我所有的东西添加到新的相对容器中(而不是替换)。

    谢谢。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-12
      • 1970-01-01
      • 2012-02-27
      • 2011-08-19
      • 1970-01-01
      • 1970-01-01
      • 2014-07-21
      相关资源
      最近更新 更多