I have a strange problem. I want to display license information viewable from the settings in the app. I am using a very simple custom DialogPreference
which just hosts a scrollveiw
with a textview
inside. Everything works fine except that on my test device running android 2.3.5 the dialog is very dark and hard to read. It works perfectly on my main device running android >4.0. What might be the problem?
What it looks like on android 2.3.5:
My XML:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="7dp"
android:orientation="vertical" >
<TextView
android:id="@+id/info_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textIsSelectable="false"
android:layout_margin="7dip" />
</ScrollView>
My code:
public class PreferenceDialogOpenSourceLicenses extends DialogPreference {
private String dialogeMessage;
private Context context;
public PreferenceDialogOpenSourceLicenses(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
setPersistent(false);
setDialogLayoutResource(R.layout.preference_dialog_license);
dialogeMessage = getActionBarSherlockLicense();
}
@Override
public void onBindDialogView(View view){
TextView textView = (TextView)view.findViewById(R.id.info_textview);
textView.setText(dialogeMessage);
super.onBindDialogView(view);
}
private String getActionBarSherlockLicense() {
try {
InputStream is = context.getAssets().open("licence_apache_v2.txt");
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
String text = new String(buffer);
return text;
} catch (IOException e) {
return context.getString(R.string.error_could_not_get_license);
}
}
}
Have a look at your styles.xml in your value folder! Put anything else in the parent of your app theme... That should fix the "dark" theme issue ;) ex: .Light theme
After that, you can change the styles.xml of the value-v11 folder & value-v14 folder to holo, which will take Holo theme in consideration when the API level support it!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.