【发布时间】:2015-12-25 03:42:33
【问题描述】:
我正在试用产品详细信息页面。类似这样:
用户界面看起来完美而漂亮。唯一的问题是我试图将图像列表居中。
框中的图像不在中心。尝试了重力/布局重力,但仍然无法获得相同的结果。谁能告诉我可能出了什么问题?
这是我的 XML 部分:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="12dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="380dp"
android:id="@+id/imageRelativeLayout"
android:background="@android:color/white">
<TextView
android:id="@+id/labelProductName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginTop="4dp"
android:ellipsize="end"
android:ems="12"
android:text="Over Panel Patch with Pivot"
android:textSize="16sp"/>
<TextView
android:id="@+id/labelProductModel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/labelProductName"
android:layout_marginLeft="4dp"
android:layout_marginTop="4dp"
android:ellipsize="end"
android:ems="12"
android:text="OSSPF-1"
android:textSize="12sp"
android:textStyle="bold"/>
<ImageView
android:id="@+id/imageProduct"
android:layout_width="match_parent"
android:layout_height="220dp"
android:layout_below="@+id/labelProductModel"
android:contentDescription="@string/app_name"
android:padding="4dp"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/listImages"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:layout_alignParentBottom="true"
android:layout_gravity="center"
android:layout_below="@+id/imageProduct"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:visibility="visible"/>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:id="@+id/favImage"
android:contentDescription="@string/app_name"
android:src="@drawable/ic_heart"/>
<ImageView
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_alignParentRight="true"
android:id="@+id/shareImage"
android:paddingTop="5dp"
android:layout_below="@+id/favImage"
android:contentDescription="@string/app_name"
android:src="@drawable/ic_share"/>
</RelativeLayout>
</LinearLayout>
</ScrollView>
【问题讨论】:
-
你的意思是
the image in a box是RecyclerView的一个项目对吧? -
是的。它在 RecyclerView 中。我想让 RecyclerView 位于屏幕的中心。现在最左了。。
-
对不起,我在最左边看不到 :(。你能在你的截图中解释更多
-
整个列表(BOX)从左边开始。我想像实际的 hardrive 对接屏幕截图一样展示它。
-
@PhanVănLinh:我说的是 RecyclerView 而不是 RecyclerView 中的项目
标签: android xml android-relativelayout