Java 布局Xml和图像
我用两个图像构建布局xml,并将其作为线性布局返回一个图像。 问题是,我的顶部图像在主屏幕下以10像素的速度开始,然后我看到了线性布局背景图像的顶部Java 布局Xml和图像,java,android,eclipse,android-layout,Java,Android,Eclipse,Android Layout,我用两个图像构建布局xml,并将其作为线性布局返回一个图像。 问题是,我的顶部图像在主屏幕下以10像素的速度开始,然后我看到了线性布局背景图像的顶部 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/hazmanag" android:layout_gravity="top">
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/uph"
android:layout_gravity="top|center"/>
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/coupon" android:layout_gravity="top|center"/>
</LinearLayout>
您应该尝试以下方法:
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop = "50dp"
android:src="@drawable/uph"
android:layout_gravity="top|center"/>
您已经在所有方向上定义了android页边距(顶部、底部、左侧和右侧),因此您可以将对象放置在屏幕中的任何位置 当你说它在主屏幕下启动10px时,你是在说标题栏吗?我有主屏幕,在状态栏下显示背景图像,只有在状态栏10-20px后,第一个图像才显示。我会尝试专门设置边距。如果你没有我的,你可以清楚地告诉你的pblm。