2017-05-10 2 views
-1

Ich möchte ein Showcase auf Überlaufsymbol aus dem Menü anzeigen.Verweis auf Überlaufsymbol anzeigen

Dies ist mein Code:

ShowcaseConfig config = new ShowcaseConfig(); 
config.setDelay(500); // half second between each showcase view 

MaterialShowcaseSequence sequence = new MaterialShowcaseSequence(this, "5"); 

sequence.setConfig(config); 
sequence.addSequenceItem(((ViewGroup) tabLayout.getChildAt(0)).getChildAt(0), 
     "Sync your data by turn on the switch", "GOT IT"); 

Ich brauche einen Verweis auf die View von Überlauf-Symbol, um nächste Vitrine Sequenz hinzuzufügen:

sequence.addSequenceItem(?, "Click here to display menu", "GOT IT"); 

Wie diese View die Referenz bekommen?

Antwort

0

Es ist ein bisschen schwierig, die View des Überlaufsymbols zu erwerben.

This Antwort wird darauf hinweisen, einen Weg, dies zu tun. Zusammenfassend sollten folgende Änderungen vorgenommen werden.

In styles.xml:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    ... 
    <item name="actionOverflowButtonStyle">@style/MyActionOverflowButtonStyle</item> 
</style> 

<style name="MyActionOverflowButtonStyle" parent="Widget.AppCompat.ActionButton.Overflow"> 
    <item name="android:contentDescription">@string/my_custom_content_description</item> 
</style> 

In strings.xml:

<string name="my_custom_content_description">some description</string> 

In Tätigkeit des onCreate():

// The content description used to locate the overflow button 
final String overflowDesc = getString(R.string.my_custom_content_description); 
// The top-level window 
final ViewGroup decor = (ViewGroup) getWindow().getDecorView(); 
// Wait until decor view is laid out 
decor.post(new Runnable() { 
    @Override 
    public void run() { 
     // The List that contains the matching views 
     final ArrayList<View> outViews = new ArrayList<>(); 
     // Traverse the view-hierarchy and locate the overflow button 
     decor.findViewsWithText(outViews, overflowDesc, 
       View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION); 
     // Guard against any errors 
     if (outViews.isEmpty()) { 
      return; 
     } 
     // Do something with the view 
     final ImageView overflowIcon = (ImageView) outViews.get(0); 
     sequence.addSequenceItem(overflowIcon, "Click here to display menu", "GOT IT"); 
    } 
});