我在我的一项活动中遇到了一些与布局有关的问题。以下是我目前有:将视图带到图像视图的前端 - Android XML
正如你所看到的,绿色的圆圈是头图像下面,即使它应该在顶部重叠。此外,正如您所看到的,圆圈右侧的文本位于标题图片下方,即使它应位于下方的一行中。
这是我目前的XML(我已经排除不相干的东西):
<ScrollView
android:id="@+id/scroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<RelativeLayout
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="match_parent"
android:layout_height="135dp"
android:id="@+id/headerImageView"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" android:layout_alignParentLeft="true"
android:scaleType="centerCrop"
android:adjustViewBounds="false"
android:background="@drawable/header_image_test" />
<Button
android:layout_width="49dp"
android:layout_height="49dp"
android:layout_alignBottom="@id/headerImageView"
android:layout_alignRight="@id/headerImageView"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/star"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/headerImageView"
android:orientation="horizontal"
android:id="@+id/main_details_layout">
<TextView
android:id="@+id/waitTimeTextView"
android:layout_width="90dp"
android:layout_height="90dp"
android:text="@string/wait_time_default"
android:layout_marginLeft="8dp"
android:layout_marginRight="16dp"
android:gravity="center"
android:background="@drawable/color0"
android:textColor="#FFFFFF"
android:layout_marginTop="-30dp"
android:textSize="30dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.7"
android:text="Attraction Name"
android:textSize="23dp"
android:layout_marginRight="8dp"
android:gravity="bottom"
android:lines="1"
android:id="@+id/attractionNameTextView"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Last Updated"
android:textSize="16dp"
android:layout_marginRight="8dp"
android:gravity="bottom"
android:id="@+id/updatedTextView"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>
对于文字,我已经试过强制行数为1,并具体设置高度,但似乎都没有奏效。另外,对于我已经尝试将代码转移到前端的循环,但它会弄乱布局。
任何人有任何改变建议?
您可以通过给顶边距等于图像高度检查试试? –
也删除textview的负边距 –