Android 相互重叠的组件
因为我对安卓系统还不熟悉,所以我试着建立一个科学计算器。因此,我有一个Android 相互重叠的组件,android,Android,因为我对安卓系统还不熟悉,所以我试着建立一个科学计算器。因此,我有一个编辑文本,显示计算结果 现在我所做的是在它上面提供一个按钮,这样,人们可以访问计算器的高级功能 我读了各种各样的问题,并试图这样做,但它似乎不起作用 很明显,它们是重叠的 但是edittext出现在imagebutton的顶部,这使得任何单击imagebutton的事件都毫无用处 代码 <ImageButton android:contentDescription="View advance featur
编辑文本
,显示计算结果
现在我所做的是在它上面提供一个按钮,这样,人们可以访问计算器的高级功能
我读了各种各样的问题,并试图这样做,但它似乎不起作用
很明显,它们是重叠的
但是edittext
出现在imagebutton
的顶部,这使得任何单击imagebutton
的事件都毫无用处
代码
<ImageButton
android:contentDescription="View advance features"
android:layout_width="50dp"
android:layout_height="50dp"
android:id="@+id/go_advance"
android:scaleType="fitXY"
android:layout_alignParentTop="@id/linearLayout"
android:layout_alignParentBottom="@id/linearLayout"
android:background="@drawable/round_buttons"
/>
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintEnd_toStartOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<EditText
android:id="@+id/editText3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill_horizontal"
android:height="225dp"
android:textSize="24sp"
android:gravity="end|bottom"
android:ems="10"
android:maxLines="2"
android:inputType="textMultiLine"
tools:layout_editor_absoluteX="104dp"
tools:layout_editor_absoluteY="207dp" />
如何将我的
imagebutton
放在edittext
的顶部?我猜您正在使用RelativeLayout作为父布局。将图像按钮放在LinearLayout之后
<RelativeLayout>
<LinearLayout>
...
edit text, buttons etc
...
</LinearLayout>
<ImageButton/>
</RelativeLayout>
...
编辑文本、按钮等
...
我认为不需要线性布局。我会使用GridLayout而不是RelativeLayout,它似乎是这个UI的完美容器。相对>线性(编辑文本+网格布局),图像按钮
这是真实的结构我明白了,你想说的,谢谢@BernoulliGate