我有一个ImageButton和一个相同大小的宽度和高度的相对视图内的TextView。默认情况下,TextView被禁用,ImageButton被启用。但是,在这种情况下,我无法点击ImageButton。对彼此的两个意见,但只显示一个?
当我启用TextView并禁用ImageButton时,我可以点击TextView。我认为这是因为它在XML中的ImageButton下。
有没有人知道我怎么能得到这种“切换”功能,其中两个项目的大小相同,但是其中只有一个是可点击的。
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp">
<ImageButton
android:id="@+id/pp_note_1"
android:layout_width="150dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:background="@android:color/white"/>
<AutoCompleteTextView
android:enabled="false"
android:id="@+id/pp_autonote_1"
android:layout_alignParentRight="true"
android:layout_width="150dp"
android:layout_height="50dp" />
</RelativeLayout>
你可以让你的生活更轻松,并使用ViewSwitcher。或者不要禁用尝试将可见性设置为通过。 – ElDuderino
@ElDuderino他从来没有听说过ViewSwitcher,我可以看看这个。另外,如果更改可见性,我可以使用背景吗? – Brejuro
如果将ImageButton的可见性设置为GONE,ImageButton的背景将不会再显示。如果您需要两个视图的背景,请将其设置为RelativeLayout或ViewSwitcher,然后再使用它。您当然也可以将它设置为TextView,这样两个视图都有背景。 – ElDuderino