我有一个奇怪的问题。我想显示可从应用程序中的设置查看的许可证信息。我正在使用一个非常简单的自定义DialogPreference
,它只是在里面托管scrollveiw
一个textview
。一切正常,除了在我运行 android 2.3.5 的测试设备上,对话框非常暗且难以阅读。它在我运行 android > 4.0 的主设备上完美运行。可能是什么问题?
它在 android 2.3.5 上的样子:
我的 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>
我的代码:
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);
}
}
}