Created
September 12, 2016 01:40
-
-
Save wbspry/4cc2179f86d357d75c1c4fce15cff58b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MultiLineSwitchPreference extends SwitchPreference { | |
public MultiLineSwitchPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { | |
super(context, attrs, defStyleAttr, defStyleRes); | |
} | |
public MultiLineSwitchPreference(Context context, AttributeSet attrs, int defStyleAttr) { | |
super(context, attrs, defStyleAttr); | |
} | |
public MultiLineSwitchPreference(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} | |
public MultiLineSwitchPreference(Context context) { | |
super(context); | |
} | |
protected void onBindView(View view){ | |
super.onBindView(view); | |
adjustViews(view); | |
} | |
protected void adjustViews( View view){ | |
if ( view instanceof ViewGroup){ | |
ViewGroup group=(ViewGroup)view; | |
for ( int index = 0; index < group.getChildCount(); index++) | |
adjustViews(group.getChildAt(index)); | |
} else if (view instanceof TextView){ | |
// adjust your textViews here | |
TextView t = (TextView)view; | |
t.setSingleLine(false); | |
t.setEllipsize(null); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SwitchPreferenceを拡張してTitleを複数行表示できるようにしたもの。
Androidのバグで拡張するとスイッチのアニメーションが効かなくなる。
https://code.google.com/p/android/issues/detail?id=212142)