2016-05-10 53 views
0

我的XML看起來是這樣,我在XML中的顏色實際的佈局並不反映

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 

    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:background="@drawable/blackboard" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin"> 
    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/scroll_view_qr_lost"> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_marginBottom="50dp" 
      android:orientation="vertical"> 
      <android.support.v7.widget.CardView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:padding="10dp" 
       android:layout_margin="15dp" 
       android:background="#ccc" 
       android:orientation="horizontal"> 
       <EditText 
        android:layout_width="match_parent" 
        android:layout_margin="15dp" 
        android:textColor="#222" 
        android:hint="Type School Name * " 
        android:id="@+id/school_name_activity_lost_qr" 
        android:textColorHint="#6d0d" 
        android:gravity="center" 
        android:layout_height="wrap_content" /> 
      </android.support.v7.widget.CardView> 

      <android.support.v7.widget.CardView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:padding="10dp" 
       android:layout_margin="15dp" 
       android:background="#ccc" 
       android:orientation="horizontal"> 
       <EditText 
        android:layout_width="match_parent" 
        android:layout_margin="15dp" 
        android:textColor="#222" 

        android:hint="Type Student's Name * " 
        android:id="@+id/student_name_activity_lost_qr" 
        android:textColorHint="#6d0d" 
        android:gravity="center" 
        android:layout_height="wrap_content" /> 
      </android.support.v7.widget.CardView> 

      <android.support.v7.widget.CardView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:padding="10dp" 
       android:layout_margin="15dp" 
       android:background="#ccc" 
       android:orientation="horizontal"> 
       <EditText 
        android:layout_width="match_parent" 
        android:layout_margin="15dp" 
        android:textColor="#222" 
        android:hint="Type Student's Class * " 
        android:id="@+id/class_no_activity_lost_qr" 
        android:textColorHint="#6d0d" 
        android:gravity="center" 
        android:layout_height="wrap_content" /> 
      </android.support.v7.widget.CardView> 

      <android.support.v7.widget.CardView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:padding="10dp" 
       android:layout_margin="15dp" 
       android:background="#000" 
       android:orientation="horizontal"> 
       <EditText 
        android:layout_width="match_parent" 
        android:layout_margin="15dp" 
        android:hint="Type Section (If any) " 
        android:textColor="#222" 
        android:id="@+id/student_section_activity_lost_qr" 
        android:textColorHint="#6d0d" 
        android:gravity="center" 
        android:layout_height="wrap_content" /> 
      </android.support.v7.widget.CardView> 
      <android.support.v7.widget.CardView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:padding="10dp" 
       android:layout_margin="15dp" 
       android:background="#ccc" 
       android:orientation="horizontal"> 
       <EditText 
        android:layout_width="match_parent" 
        android:layout_margin="15dp" 
        android:hint="Type Student's Roll No * " 
        android:id="@+id/student_roll_no_activity_lost_qr" 
        android:textColorHint="#6d0d" 
        android:gravity="center" 
        android:textColor="#222" 
        android:inputType="number" 
        android:layout_height="wrap_content" /> 
      </android.support.v7.widget.CardView> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="* fields must be entered, \nPlease press the blue floating button to submit. " 
       android:gravity="center" 
       android:layout_marginBottom="10dp" 
       android:textColor="#ccc"/> 

      <android.support.design.widget.FloatingActionButton 
       android:id="@+id/fab_submit_lost_qr_application" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" 
       android:clickable="true" 
       android:layout_alignParentBottom="true" 
       app:backgroundTint="@color/colorPrimaryii" 
       android:layout_centerInParent="true" 
       android:layout_margin="@dimen/fab_margin" 
       android:src="@android:drawable/ic_menu_send" /> 


     </LinearLayout> 

    </ScrollView> 

</RelativeLayout> 

而且我的屏幕本來應該是這樣的。 This is the screen generated by the IDE and it should look like this in real

但我在實際設備的屏幕看起來是這樣的,

enter image description here

所以任何人都可以提出什麼與我的程序的問題呢?

P.S.早期的顏色工作得很好。

+0

由於您在CardView中編寫了'android:background =「#ccc」',它會不會是預期的顏色?嘗試將它改爲'android:background =「#ffffff」' –

+0

no #ccc是一種顏色,它是白色但不是絕對白色,因爲#ffffff – erluxman

+0

沒問題。我能想到的另一件事,你是否改變了任何風格或主題? –

回答

2

它看起來像CardView使用不同的屬性來設置背景顏色。

嘗試使用應用程序:cardBackgroundColor = 「#CCC」

0

嘗試:

card_view:cardBackgroundColor="#ccc" 

記住聲明:

xmlns:card_view="http://schemas.android.com/apk/res-auto" 
1

您需要使用的應用程序的工具卡視圖,所以只需更改app:cardbackgroundcolor =「#ccc」而不是android:background =「#ccc」

+0

謝謝你這麼多 – erluxman

相關問題