我有一個簡單的XML:
添加一個背景圖像的RelativeLayout隱藏所有其他元素
<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="match_parent"
tools:context=".LoginActivity"
android:background="@drawable/login_background">
<LinearLayout
android:orientation="vertical"
android:layout_width="320dp"
android:layout_height="160dp"
android:layout_alignParentBottom="true"
android:layout_marginStart="218dp"
android:layout_marginBottom="25dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/editText"
android:textColor="@color/surtimax_gris_texto"
android:layout_gravity="center_horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textStyle="bold"
android:hint="@string/login_edittext_user_text"
android:textColorHint="@color/surtimax_gris_texto" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/editText2"
android:background="@drawable/login_edittext_background"
android:textColor="@color/surtimax_gris_texto"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textStyle="bold"
android:hint="@string/login_edittext_pass_text"
android:textColorHint="@color/surtimax_gris_texto" />
</LinearLayout>
</RelativeLayout>
的問題是:無論是在模擬器或實際設備顯示的LinearLayout和EditText上當的RelativeLayout有一個背景。
如果我只是刪除背景一切正常......這很奇怪。
沒有關於應用程序的錯誤日誌。
的minSdkVersion 17
targetSdkVersion 22
修訂 及其與正常的背景圖像(非9patch)工作。所以問題是關於背景9patch圖像。
更新2 有很多關於所以在使用的背景問題9patch /答案,而是因爲我所面臨的問題是應用的背景,我開始在谷歌尋找「背景圖片的問題」。當然,谷歌的結果都沒有給我任何有用的答案。當凱給我提出了關於這個問題的建議時,我很容易發現問題。所以我不打算解決這個問題,因爲它可以幫助有人通過。
login_background是9patch,並且如果將背景更改爲其他drawable,是否會發生同樣的情況? – Kai
是的,login_background是9patch,但我還沒有嘗試過使用其他的drawable。我明天再試。 – MiguelHincapieC
@ peter它不會出現正常的背景圖像。你知道我能做些什麼來解決它嗎? – MiguelHincapieC