1
我不明白,为什么如果把一个背景图片放到我的RelativeLayout布局(按钮,编辑文本,TextViews)中的视图全部放错了位置。为什么如果我改变了我的RelativeLayout的背景布局项目的位置改变?
这是它的外观之前,我把背景图片:
这是XML:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MenuActivity" >
<View
android:id="@+id/view1"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_centerInParent="true"
android:layout_margin="20dip"
android:background="@android:color/darker_gray" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:scaleType="fitXY"
android:src="@android:color/white" />
<EditText
android:id="@+id/bikenumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/getbikebutton"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_marginTop="20dip"
android:ems="10"
android:hint="Get Bikes"
android:inputType="number"
android:singleLine="true" >
<requestFocus />
</EditText>
<Button
android:id="@+id/getbikebutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/view1"
android:layout_alignLeft="@+id/view1"
android:layout_alignRight="@+id/view1"
android:layout_marginBottom="10dip"
android:layout_marginLeft="15dip"
android:layout_marginRight="15dip"
android:text="FindBikes" />
<Button
android:id="@+id/buttonGoToMyLoc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/view1"
android:layout_alignRight="@+id/view1"
android:layout_below="@+id/view1"
android:layout_marginBottom="10dip"
android:layout_marginLeft="15dip"
android:layout_marginRight="15dip"
android:text="NearMe" />
<Button
android:id="@+id/buttonGoToThisLoc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/view1"
android:layout_alignRight="@+id/view1"
android:layout_below="@+id/buttonGoToMyLoc"
android:layout_marginLeft="15dip"
android:layout_marginRight="15dip"
android:layout_marginTop="10dip"
android:text="Near Address" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/imageView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="25dip"
android:text="Title"
android:textColor="@android:color/black"
android:textSize="20dip"
android:textStyle="bold" />
<EditText
android:id="@+id/locAddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/imageView1"
android:layout_alignRight="@+id/imageView1"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_marginTop="10dip"
android:ems="10"
android:hint="Addresss"
android:inputType="text"
android:singleLine="true"
android:textColor="@android:color/black"
android:visibility="gone" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/locAddressCity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/imageView1"
android:layout_alignRight="@+id/imageView1"
android:layout_below="@+id/locAddress"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:ems="10"
android:hint="Address City"
android:inputType="text"
android:singleLine="true"
android:visibility="gone" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
现在,如果我把这个图像作为背景:
所以,如果我把android:background="@drawable/bgland"
,这是我的布局看起来像:
正如你可以看到布局misplaces的按钮。
是的,你是对的,我已经导入你的代码在我的日食,它确实使得它非常奇怪,当你设置背景。 –
@Lisa尝试给LinearLayout的背景,我认为它会起作用。 –
@pratik嗨pratik,谢谢你:-)不幸的是我已经尝试将图像设置为LinearLayout的背景,但没有成功: - ((没有任何更改: - (( –