我可以更改我的编辑文本首选项的标题和摘要颜色。当你点击它时,我的背景是黑色的,按钮是白色的。我仍然需要弄清楚如何更改实际值文本。有任何想法吗?
如果我也能改变那条线的颜色就好了。
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.Context;
import android.graphics.Typeface;
import android.preference.EditTextPreference;
import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.kisnardonline.kisnardonline.GameActivity;
import com.kisnardonline.kisnardonline.R;
@SuppressLint("AppCompatCustomView")
public class FontEditTextPreference extends EditTextPreference {
public FontEditTextPreference(Context context) {
super(context);
}
public FontEditTextPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public FontEditTextPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected View onCreateView(ViewGroup viewGroup) {
Typeface customFont = FontCache.getTypeface("UnderwoodChampionRegular.ttf", GameActivity.commandReceiver.activity_settings);
View v = super.onCreateView(viewGroup);
try {
TextView titleView = (TextView) v.findViewById(android.R.id.title);
titleView.setTypeface(customFont);
titleView.setTextColor(ContextCompat.getColor(GameActivity.commandReceiver.activity_settings, R.color.THEME_LIGHT_TEXT));
TextView summaryView = (TextView) v.findViewById(android.R.id.summary);
summaryView.setTypeface(customFont);
summaryView.setTextColor(ContextCompat.getColor(GameActivity.commandReceiver.activity_settings, R.color.THEME_LIGHT_TEXT));
} catch (Exception e) {
Log.e("jay", "Exception in FontEditTextPreference", e);
}
return v;
}
@Override
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
super.onPrepareDialogBuilder(builder);
builder.getContext().setTheme(R.style.JayPreferenceThemeDialog);
}
}
我的风格在这里:
<style name="JayPreferenceThemeDialog" >
<item name="android:colorBackground">@color/THEME_LIGHTER_BACKGROUND</item>
<item name="android:textColor">@android:color/background_light</item>
<item name="android:textColorSecondary">@android:color/background_light</item>
</style>