Ich brauche einen Regenbogeneffekt auf den Titel, wieandroid Titel mit Regenbogen-Effekt
Bild hinzuzufügen.
Irgendwelche Ideen?
Ich fand einige Antworten für Textview, aber nichts für den Titel in der Symbolleiste
Ich brauche einen Regenbogeneffekt auf den Titel, wieandroid Titel mit Regenbogen-Effekt
Bild hinzuzufügen.
Irgendwelche Ideen?
Ich fand einige Antworten für Textview, aber nichts für den Titel in der Symbolleiste
public static TextView getToolbarTitleView(ActionBarActivity activity, Toolbar toolbar){
ActionBar actionBar = activity.getSupportActionBar();
CharSequence actionbarTitle = null;
if(actionBar != null)
actionbarTitle = actionBar.getTitle();
actionbarTitle = TextUtils.isEmpty(actionbarTitle) ? toolbar.getTitle() : actionbarTitle;
if(TextUtils.isEmpty(actionbarTitle)) return null;
// can't find if title not set
for(int i= 0; i < toolbar.getChildCount(); i++){
View v = toolbar.getChildAt(i);
if(v != null && v instanceof TextView){
TextView t = (TextView) v;
CharSequence title = t.getText();
if(!TextUtils.isEmpty(title) && actionbarTitle.equals(title) && t.getId() == View.NO_ID){
//Toolbar does not assign id to views with layout params SYSTEM, hence getId() == View.NO_ID
//in same manner subtitle TextView can be obtained.
return t;
}
}
}
return null;
}
TextView tv= getToolBarTitleView(activity,toolbar);
if(tv!=null){
Shader textShader=new LinearGradient(0, 0, 0, 20,
new int[]{Color.YOURCOLOR,Color.YOURCOLOR},
new float[]{0, 1}, TileMode.CLAMP);
tv.getPaint().setShader(textShader);
}
else{
Log.e("MYPROJECT","No textview in toolbar . . . ");
}
thx, ich habe Ihre getToolbarTitleView() in Kombination mit dem GitHub Link aus dem ersten Kommentar und es hat funktioniert :) –
glücklich, Ihnen zu helfen :) –
Sie können einen Rat hier gepostet verwenden https://chiuki.github.io/advanced-android-textview/#/ 38, um Ihren benutzerdefinierten RainbowSpan zu erstellen und dann SpannableString als Titel zu verwenden. –
thx, ich habe Ihren Rat in Kombination mit Arsen Sench Antwort verwendet und es funktioniert –