2013-10-05 2 views
14

ショーケースビューでタイトルとメッセージの位置を設定する方法はありますか?私はライブラリが最高の位置を見つけるために関数を使っているのを見ますが、それを上書きしたいのです。ショーケーステキストの重力を表示

+1

あなたが何を言っているのかを具体的に説明し、コードを示して、あなたが得ている問題について説明してください。 –

+0

更新されたop。まだこれを行う方法が見つかりませんでした。 – arayray

+0

Showcase View githubの発行された問題。 https://github.com/Espiandev/ShowcaseView/issues/113 – arayray

答えて

8

私はちょうどShowcaseViewのソースコードを掘り下げました。テキストの位置を設定する方法はありません。だから私は自分自身の変更をライブラリに追加しました。これらのフィールドを追加したクラスShowcaseView

:ここで私が行った変更である

private boolean hasManualPostion = false; 
private int xPosition, yPosition, width; 

次にShowcaseViewクラスの内部クラスですBuilderクラスでは、これらのメソッドを追加します。

 public Builder hasManualPosition(boolean hasManualPosition) { 
     showcaseView.hasManualPostion = hasManualPosition; 
     return this; 
    } 

    public Builder xPostion(int xPostion) { 
     showcaseView.xPosition = xPostion; 
     return this; 
    } 

    public Builder yPostion(int yPostion) { 
     showcaseView.yPosition = yPostion; 
     return this; 
    } 

その後、このメソッドをTextDrawerクラスに追加します。

public void setTestPostionManually(int xPosition, int yPosition) { 
    mBestTextPosition[0] = xPosition; 
    mBestTextPosition[1] = yPosition; 
} 

と、このように見てShowcaseViewにおけるエンドチェンジonPreDraw方法で:

sv = new ShowcaseView.Builder(this, true) 
       .setTarget(target) 
       .setContentTitle(R.string.showcase_main_title) 
       .setContentText(R.string.showcase_main_message) 
       .setStyle(R.style.CustomShowcaseTheme2) 
       .setShowcaseEventListener(this) 
       .hasManualPosition(true) 
       .xPostion(0) 
       .yPostion(240) 
       .build(); 

お楽しみください:

@Override 
public boolean onPreDraw() { 
    boolean recalculatedCling = showcaseAreaCalculator.calculateShowcaseRect(showcaseX, showcaseY, showcaseDrawer); 
    boolean recalculateText = recalculatedCling || hasAlteredText; 
    if (recalculateText) { 
     textDrawer.calculateTextPosition(getMeasuredWidth(), getMeasuredHeight(), this, shouldCentreText); 
     if (hasManualPostion) { 
      textDrawer.setTestPostionManually(xPosition, yPosition); 
     } 
    } 
    hasAlteredText = false; 
    return true; 
} 

今、あなたは、このようなShowcaseViewを作成する必要があります!

+0

このバージョンはこれですか?どのようにそれを遺産の中で働かせるか考えていますか? –

+1

バージョン5.0.0の変更点 – Sadegh

+0

手アニメーションを5.0.0で使用する方法はありますか? –

関連する問題