【发布时间】:2012-03-06 02:22:58
【问题描述】:
嗯。我有一个包含三个页面的 ViewPager 的 Activity。
活动正在使用浅色主题。我已经在清单中设置了
<!-- 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>
前两页看起来正确...这是第一页的屏幕截图:
这是第三页的截图:
妈的!为什么 TextViews 采用黑色主题颜色? ViewPager 的页面是一个片段,应该继承父活动的主题...
我该怎么办?我不想强制文本颜色.....
P.S:我在其他 Activity 中有另一个 ViewPager,颜色还可以……这太奇怪了
更多代码: 活动布局(有用的代码)
<?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>
如你所见,代码很简单……我不明白这个问题。
【问题讨论】:
-
布局上 TextView 的 textColor 属性似乎被覆盖了。也许您已经应用样式并更改了颜色?请添加 XML 布局的代码。
-
我不这么认为...我没有使用任何颜色属性...布局的颜色是主题的“默认”颜色...
-
尝试在适配器布局中将属性 textColor="@color/negro" 添加到 TextView。
-
嗯...这是“简单易行”的解决方案...但是如果将来我想更改主题,那么这部分会看起来很难看,因为所有应用程序(除了这个页面这个片段的)正在遵循主题的配色方案......
-
这样显示正确的颜色?
标签: android android-activity themes android-viewpager