【问题标题】:Using layout_above/layout_below does not yield expected results. Item dissapears使用 layout_above/layout_below 不会产生预期的结果。物品消失
【发布时间】:2015-02-26 17:35:04
【问题描述】:

我有以下代码:

grid_view_item.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical">

<RelativeLayout
    android:layout_width="wrap_content"
    android:gravity="center_horizontal"
    android:layout_height="wrap_content">

    <com.entu.artapp.utils.SquareImageView
        android:id="@+id/gridItem_squareImageView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="centerCrop"
        android:visibility="invisible"/>

    <com.entu.artapp.utils.SquareImageView
        android:id="@+id/gridItem_selectedColor"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="centerCrop"
        android:background="#e85349"
        android:alpha="0.45"
        android:visibility="invisible"/>

    <com.entu.artapp.utils.SquareImageView
        android:id="@+id/gridItem_constantGrey"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="centerCrop"
        android:background="#000000"
        android:alpha="0.45"
        android:visibility="visible"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#FFFFFF"
        android:textColor="#FFFFFF"
        android:id="@+id/gridItem_textView"
        android:layout_centerInParent="true"
        android:hint="AAAAAAAAA"/>

    <ImageView
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:layout_centerHorizontal="true"
        android:src="@drawable/checkmark"
        android:id="@+id/gridItem_selectedCheckMark"
        />

    <ProgressBar
        android:id="@+id/gridItem_progressBar"
        style="?android:attr/progressBarStyleSmall"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_centerInParent="true"
        android:visibility="visible"/>

</RelativeLayout>

产生这种观点:

我希望我的项目看起来像这样:

所以,我在我的 CheckMark imageView 代码中添加了这一行:

android:layout_above="@+id/"gridItem_progressBar"

checkMark imageview 就消失了。 layout_below 也一样,如下所示:

谁能帮我解决这个问题?

干杯!

【问题讨论】:

    标签: android xml image android-relativelayout


    【解决方案1】:

    如果您使用填充而不是上方或下方可能会对您有所帮助,为什么要将线性布局作为您的父级而将相对视图作为子级,如果您将相对布局作为父级会更容易。希望这对您有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-03
      相关资源
      最近更新 更多