這對我來說有點意外。我有以下佈局文件:Button和EditText上的Android視圖不會遮擋它們
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/MyButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/Hello" />
<EditText
android:id="@+id/MyEditText"
android:layout_below="@id/MyButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/Hello" />
<LinearLayout
android:layout_centerInParent="true"
android:layout_width="100dp"
android:layout_height="match_parent"
android:background="#ffffffff">
</LinearLayout>
</RelativeLayout>
而且我期待的LinearLayout到的兩種觀點(該按鈕和EditText上的仿真結果是模糊的部分正是:
然而該裝置(A摩托3G第三代),該按鈕顯示在的LinearLayout的頂部:
此外,我仍然可以在設備和仿真器上的LinearLayout應該遮擋的部分點擊按鈕和EditText。
我的問題,然後是:我怎樣才能使線性佈局出現在設備上的按鈕的頂部?我怎樣才能防止LinearLayout上的水龍頭被重定向到按鈕並編輯文本?
謝謝。
爲了以防萬一,我使用Xamarin for Android,但它不應該是相關的。
謝謝。向LinearLayout添加android:elevation =「10dp」可修復按鈕重疊。但是線性佈局上的點擊仍然由按鈕或編輯文本處理。你知道如何解決這個問題嗎? –
很確定問題在於'LinearLayout'沒有捕獲點擊事件,所以他們被分派到更遠的視圖。你有沒有試過在LinearLayout上設置'android:clickable =「true」'? – Nathanael
是的,添加這兩個屬性解決了這兩個問題。非常感謝你。 –