I'm currently having an issue with using custom ListView adapters with the Holo.Light theme. Within the activities and fragments, any TextViews are displayed in the theme's normal colours (textColorPrimary
). However, any text within the custom ListAdapter uses textColorPrimary
from the default Holo theme, effectively making the text unreadable.
Here is an example from my app's main menu:
list_main_menu.xml - The row layout for the ListAdapter
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/imgIcon"
android:layout_height="48dip"
android:layout_width="48dip"
android:src="@drawable/ic_launcher"
/>
<TextView
android:id="@+id/txtFirstLine"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/imgIcon"
android:text="Line 1"
android:textSize="12pt"
/>
<TextView
android:id="@+id/txtSecondLine"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/imgIcon"
android:layout_below="@id/txtFirstLine"
android:text="Line 2"
/>
</RelativeLayout>
Note: I'm currently having to use android:textColor="?android:attr/textColorPrimaryInverse"
to make the text readable.
fragment_main_menu.xml - The Main Menu fragment.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/txtWelcome"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Username"
android:textSize="18sp"
/>
<ListView
android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
AndroidManifext.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.michaeldodd.treasurehunter"
android:versionCode="1"
android:versionName="0.0.1" >
<uses-sdk android:minSdkVersion="11" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name" android:name=".gui.Login"
android:theme="@android:style/Theme.Holo.Light">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".gui.Home" android:theme="@android:style/Theme.Holo.Light" />
<activity android:name=".gui.UserProfile" android:theme="@android:style/Theme.Holo.Light" />
<activity android:name=".gui.MapList" android:theme="@android:style/Theme.Holo.Light" />
</application>
</manifest>
I'm not currently using any custom styles. Thanks for reading, and any useful comments will be greatly appreciated.
EDIT 1:
Here's the requested screenshots.
This is how it looks if I don't specify the text colour, it seems to be using the default text colour for Holo Dark
Manually specifying android:textColor="?android:attr/textColorPrimaryInverse"
gives this result, but I'm uneasy at using a workaround like this.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…