2012-03-05 10 views
-1

。 3ページのViewPagerを含むアクティビティがあります。Androidレイアウトでの混合テーマ

アクティビティは、ライトテーマを使用しています。

Page 1

、これがされている:私は最初の2ページが正しく見える...これは1ページ目のscreenshootあるマニフェスト

  <!-- 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> 

でそれを設定しています第3ページのスクリーンショット:

page 3

wtf!なぜTextViewsは、黒のテーマカラーを取っているのですか? ViewPagerのページはフラグメントであり、親アクティビティのテーマを継承する必要があります。

どうすればよいですか?私は他のアクティビティに別のViewPagerを持っており、色はOKです...これは、コードのもう少し

とても奇妙です:私は

PS .....テキストの色を強制する必要はありません。 アクティビティレイアウト(有用コード)

<?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

+0

私はそうは思わない...私は色属性を使用していない...レイアウトの色は、テーマの "デフォルト"の色です... – Desenfoque

+0

プロパティをアダプタのレイアウトに追加しようとしますtextColor = "@ color/negro"をTextViewに追加します。 – sabadow

答えて

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

関連する問題