2012-03-05 41 views
-1

好吧。我有一個包含三頁ViewPager的活動。Android佈局中的混合主題

活動正在使用燈光主題。我已經在清單

  <!-- PANTALLA PEDIDO--> 
       <activity android:screenOrientation="portrait" 
        android:name="com.adelco.carro.Pedido" 
        android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"> 
        <intent-filter> 
         <action android:name="com.adelco.carro.Pedido" /> 
         <category android:name="android.intent.category.DEFAULT" /> 
        </intent-filter> 
      </activity> 

前兩個頁面看起來正確設置它...這是第1頁的screenshoot:

Page 1

,這是是第3頁的屏幕截圖:

page 3

wtf!爲什麼TextView會採用黑色主題顏色? ViewPager的頁面是一個片段,應繼承父活動的主題...

我該怎麼辦?我不想強制文本顏色.....

PS:我還有一個ViewPager在其他活動和顏色都OK ......這是如此怪異

多一點的代碼: 活動佈局(有用的代碼)

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:orientation="vertical" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 
     <RelativeLayout android:layout_width="match_parent" 
         android:layout_height="match_parent"> 
       <android.support.v4.view.ViewPager 
          android:layout_alignParentTop="true" 
          android:id="@+id/pager_informacion" 
          android:layout_width="match_parent" 
          android:layout_height="match_parent"> 
       </android.support.v4.view.ViewPager> 
    </RelativeLayout> 
</LinearLayout> 

片段佈局

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
     <TextView android:text="Artículos" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:textSize="28sp" 
        android:textStyle="bold" 
        android:gravity="center_vertical|center_horizontal" 
        android:textAppearance="?android:attr/textAppearanceMedium"> 
     </TextView> 
     <FrameLayout android:layout_width="match_parent" 
        android:layout_height="0dip" 
        android:layout_weight="1" > 
       <ListView android:id="@+id/lista_articulos" 
          android:layout_width="match_parent" 
          android:layout_height="match_parent" 
          android:dividerHeight="1dp" 
          android:divider="@color/negro"> 
       </ListView> 
     </FrameLayout> 
</LinearLayout> 

和適配器佈局

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <ImageView android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:scaleType="fitXY" 
       android:id="@+id/iv_tipo_producto"> 
    </ImageView> 
    <RelativeLayout android:layout_width="match_parent" 
        android:layout_height="match_parent"> 
     <TextView android:id="@+id/tv_descripcion" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true" 
        android:layout_alignParentLeft="true" 
        android:textStyle="bold" 
        android:textSize="16sp" 
        android:paddingLeft="5dp" 
        android:paddingRight="5dp"> 
     </TextView> 
    </RelativeLayout> 
</LinearLayout> 

正如你所看到的代碼非常簡單......我不明白這個問題。

+0

似乎佈局上的TextView的textColor屬性被覆蓋。也許你應用了樣式並改變顏色?請添加XML佈局的代碼。 – sabadow 2012-03-05 17:50:07

+0

我不這麼認爲......我沒有使用任何顏色屬性......佈局的顏色是主題的「默認」顏色... – Desenfoque 2012-03-05 17:54:50

+0

嘗試在適配器佈局中添加屬性textColor =「@ color/negro」給TextView。 – sabadow 2012-03-05 18:10:29

回答

2

我覺得問題是調用方法來填充listView的方式。很可能傳遞給應用程序的上下文不正確,不保留應用程序主題。

嘗試傳遞Activity上下文,而不是調用getAplicacionContext()。

像這樣:

dataSource = new MyCursorAdapter(getActivity(), R.layout.myrow, data, 
     fields, new int[] { R.id.field1, R.id.field2 }); 

更多信息:Custom ListView in Fragment not adhering to parent theme

希望它能幫助。

+0

是!....我使用「getActivity()。getApplicationContext()」,並將其更改爲「getActivity()」....現在可以使用了!謝謝。 – Desenfoque 2012-03-05 18:28:13