Mercurial > gmapzoominvert
comparison XposedLibrary/src/de/robv/android/xposed/library/ui/TextViewPreference.java @ 0:3da8a7a621cd
Initial commit
author | Brad Greco <brad@bgreco.net> |
---|---|
date | Mon, 20 Jan 2014 22:56:13 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3da8a7a621cd |
---|---|
1 package de.robv.android.xposed.library.ui; | |
2 | |
3 import android.content.Context; | |
4 import android.graphics.Typeface; | |
5 import android.preference.Preference; | |
6 import android.util.AttributeSet; | |
7 import android.view.View; | |
8 import android.view.ViewGroup; | |
9 import android.widget.TextView; | |
10 | |
11 public class TextViewPreference extends Preference { | |
12 private TextView textView = null; | |
13 private int padding = 7; | |
14 private int textSize = -1; | |
15 private boolean bold = false; | |
16 private boolean italic = false; | |
17 | |
18 public TextViewPreference(Context context, AttributeSet attrs, int defStyle) { | |
19 super(context, attrs, defStyle); | |
20 | |
21 if (attrs != null) { | |
22 textSize = attrs.getAttributeIntValue(null, "textSize", textSize); | |
23 padding = attrs.getAttributeIntValue(null, "padding", padding); | |
24 bold = attrs.getAttributeBooleanValue(null, "bold", bold); | |
25 italic = attrs.getAttributeBooleanValue(null, "italic", italic); | |
26 } | |
27 } | |
28 | |
29 public TextViewPreference(Context context, AttributeSet attrs) { | |
30 this(context, attrs, android.R.attr.preferenceStyle); | |
31 } | |
32 | |
33 public TextViewPreference(Context context) { | |
34 this(context, null); | |
35 } | |
36 | |
37 @Override | |
38 protected View onCreateView(ViewGroup parent) { | |
39 return getTextView(); | |
40 } | |
41 | |
42 public TextView getTextView() { | |
43 if (textView == null) { | |
44 textView = new TextView(getContext()); | |
45 textView.setId(android.R.id.title); | |
46 textView.setPadding(padding,padding,padding,padding); | |
47 | |
48 if (textSize > 0) | |
49 textView.setTextSize(textSize); | |
50 | |
51 if (bold && italic) | |
52 textView.setTypeface(null, Typeface.BOLD_ITALIC); | |
53 else if (bold) | |
54 textView.setTypeface(null, Typeface.BOLD); | |
55 else if (italic) | |
56 textView.setTypeface(null, Typeface.ITALIC); | |
57 } | |
58 return textView; | |
59 } | |
60 } |