gpt4 book ai didi

android - 相对布局 : why do not my buttons show below the line?

转载 作者:行者123 更新时间:2023-11-29 14:49:18 24 4
gpt4 key购买 nike

在我的 RelativeLayout 中,我试图在屏幕的后半部分放置两个按钮,

在我使用 View 创建的一行下方。

但按钮不会显示在行下方 (view1)

这是我的 XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bgland"
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" >

<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="@drawable/white_bg" />

<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="@string/hint_getbike"
android:inputType="number"
android:singleLine="true" >

<requestFocus />
</EditText>

<Button
android:id="@+id/getbikebutton"
style="@style/OrangeButtonStyle"
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="@string/menu_getbikebuttontext" />

<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" />

<Button
android:id="@+id/buttonGoToMyLoc"
style="@style/OrangeButtonStyle"
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="@string/menu_text_near_me" />

<Button
android:id="@+id/buttonGoToThisLoc"
style="@style/OrangeButtonStyle"
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="@string/menu_text_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="@string/menu_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="@string/menu_hint"
android:inputType="text"
android:singleLine="true"
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="@string/menu_hint_city"
android:inputType="text"
android:singleLine="true"
android:visibility="gone" />

</RelativeLayout>

这是图形结果:如您所见,2 个按钮位于中间线 (view1) 上方(而不是下方,它们应该位于下方)。

enter image description here

最佳答案

或者您必须在 RelativeLayout 上设置 android:layout_height="match_parent"。然后它将知道占用所有可用位置并将 view1 居中。

或者您可以将 android:layout_below="@+id/getbikebutton" 放在 view1 上。

关于android - 相对布局 : why do not my buttons show below the line?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23783801/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com