[英]How do I get buttons not to sit on top of each other in RelativeLayout
[英]Can't get imageview to sit flush with the top of the screen
我试图将图像视图放置在屏幕顶部,但是它在上方和下方都有某种类型的边距。 所以我尝试了AdjustViewBounds = true,它可以正常工作,但随后无法到达屏幕两侧。 我只希望它与屏幕顶部齐平,并到达侧面。 有什么建议么?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
tools:context="${packageName}.${activityClass}"
android:orientation="vertical" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/title_bar"/>
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="200dp" >
<LinearLayout
android:id="@+id/goals"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="@android:color/black" >
</RelativeLayout>
如果标题栏仅是彩色的,则仅使用View并将背景属性设置为所需的颜色是有意义的。 如果您具有自定义图像,并且无法使用默认的ImageView属性进行调整-那么您可以从图像中制作9Patch并将其用作背景(在9patch中,您可以自行决定如何抓取图像以及在哪里放置内容)。 您可以在android SDK中找到9patch工具。 有关9patch的更多信息: http : //developer.android.com/reference/android/graphics/NinePatch.html
我有同样的问题。 我最终要做的是在ImageView的顶部使用负边距,如下所示:
android:layout_marginTop="-4dp"
您可能需要四处寻找最佳的dp数量。 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.