java Android网格布局与部分文本重叠
所以我正在创建这个应用程序,它将在网格中显示产品,例如在nexus 7纵向视图中,每行显示2个,而在横向模式中,每行显示4个。 每个产品都有一个imagine,然后在它下面的几个文本视图中显示一些信息
然而,显示免费送货和特价数量的最后两个文本视图似乎与下图重叠。谁能帮我指出哪里出了问题。布局如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:gravity="center_horizontal"
安卓:orientation="vertical" >
<RelativeLayout
安卓:layout_width="200dp"
安卓:layout_height="200dp"
安卓:background="@drawable/product_grid_lister_image_background"
安卓:padding="1dp" >
<ProgressBar
安卓:id="@+id/image_loading"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_centerInParent="true"
安卓:indeterminateDrawable="@drawable/progress_blue" />
<ImageView
安卓:id="@+id/product_grid_lister_image"
安卓:layout_width="200dp"
安卓:layout_height="200dp"
安卓:layout_margin="10dp"
安卓:scaleType="center"/>
</RelativeLayout>
<RatingBar
安卓:id="@+id/product_grid_lister_rating_bar"
style="@style/GoldRatingBar.Large"
安卓:layout_width="wrap_content"
安卓:layout_height="18dp"
安卓:layout_marginTop="5dp"
安卓:numStars="5" />
<TextView
安卓:id="@+id/product_grid_lister_product_name_text"
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:ellipsize="end"
安卓:lines="2"
安卓:includeFontPadding="false"
安卓:textColor="@color/black"
安卓:textSize="@dimen/text_dp_14pt" />
<RelativeLayout
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content">
<TextView
安卓:id="@+id/product_grid_lister_price_text"
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:includeFontPadding="false"
安卓:textColor="@color/black"
安卓:textSize="@dimen/text_dp_20pt" />
<TextView
安卓:id="@+id/product_grid_lister_was_price_text"
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:layout_below="@id/product_grid_lister_price_text"
安卓:includeFontPadding="false"
安卓:textColor="@color/grey"
安卓:textSize="@dimen/text_dp_14pt" />
<TextView
安卓:id="@+id/product_grid_lister_offer_text"
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:layout_below="@id/product_grid_lister_was_price_text"
安卓:includeFontPadding="false"
安卓:textColor="@color/red"
安卓:textSize="@dimen/text_dp_14pt" />
<TextView
安卓:id="@+id/product_grid_lister_special_offer_text"
style="@style/plp_special_offer"
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:layout_below="@id/product_grid_lister_offer_text"
安卓:includeFontPadding="false"
安卓:text="@string/plp_special_offer" />
<TextView
安卓:id="@+id/product_grid_lister_delivery_offer_text"
style="@style/plp_special_offer"
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:layout_below="@id/product_grid_lister_special_offer_text"
安卓:includeFontPadding="false"
安卓:text="@string/plp_delivery_offer" />
<CheckBox
安卓:id="@+id/product_grid_lister_star_checkbox"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_alignParentRight="true"
安卓:paddingTop="6dp"
安卓:paddingBottom="6dp"
安卓:paddingLeft="6dp"
安卓:button="@drawable/product_grid_star_checkbox"
安卓:focusable="false" />
</RelativeLayout>
</LinearLayout>
# 1 楼答案
您缺少名称空间声明和根布局。您需要一个根布局来锚定中的所有其他内容。根据你的需要,也许一个线性布局就可以了。下面,我将所有内容包装在垂直方向的线性布局中。如果这能帮你解决任何问题,请告诉我