2016-07-21 69 views
0

我使用https://github.com/amlcurran/ShowcaseView庫創建了展示視圖。默認情況下,展示視圖圓圈指向元素的中心。 enter image description here如何更改android showcaseview圓圈位置?

我想這個圈子移動到的TextView的開始

請幫我

更新

我的佈局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.bm.eg.activities.CreateProfileActivity"> 

    <LinearLayout 

      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 

      <include layout="@layout/toolbar_transparent" /> 

       <TextView 
        android:id="@+id/tv_title" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginBottom="8dp" 
        android:layout_marginLeft="40dp" 
        android:layout_marginRight="40dp" 
        android:layout_marginTop="8dp" 
        android:ellipsize="end" 
        android:hint="@string/hint_title" 
        android:singleLine="true" 
        android:textColor="@android:color/white" 
        android:textColorHint="@color/white_transparency_50" 
        android:textSize="24sp" /> 

在活動

 mTVTitle = (TextView) findViewById(R.id.tv_title); 

     mShowcaseView = new ShowcaseView.Builder(this) 

       .setTarget(new ViewTarget(mTVTitle)) 
       .setContentTitle(getString(R.string.sv_create_profile_title)) 
       .setContentText(getString(R.string.sv_create_profile_title_description)) 
       .setStyle(R.style.CustomShowcaseTheme2) 
       .blockAllTouches() 
       .replaceEndButton(R.layout.showcase_view_cusom_button) 

       .build(); 
+0

你如何設置'.setTarget(新ActionViewTarget(這一點,ActionViewTarget.Type.HOME))' –

+0

mTVTitle =(TextView的)findViewById(R.id.tv_title)?; .setTarget(new ViewTarget(mTVTitle)) –

回答

2

最後,在研究你的問題後,我找到了你的解決方案。

你必須修改layout design添加在您的設計多了一個RelativeLayout像下面並添加在它TextViews,包括在它的tv_titlehack_txt TextView中像下面。

注:hack_txt機器人:提示= 「AAAAAA」 必須將其添加5或6字符並設置android:visibility="invisible"

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.bm.eg.activities.CreateProfileActivity"> 

    <LinearLayout 

     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <include layout="@layout/toolbar_transparent" /> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="8dp" 
      android:layout_marginLeft="40dp" 
      android:layout_marginRight="40dp" 
      android:layout_marginTop="8dp"> 

      <TextView 
       android:id="@+id/tv_title" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:ellipsize="end" 
       android:hint="@string/hint_title" 
       android:singleLine="true" 
       android:textColor="@android:color/white" 
       android:textColorHint="@color/white_transparency_50" 
       android:textSize="24sp" /> 

      <TextView 
       android:id="@+id/hack_txt" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:ellipsize="end" 
       android:hint="aaaaaa" 
       android:textSize="24sp" 
       android:visibility="invisible" /> 
     </RelativeLayout> 



     <!--... your other view--> 
    </LinearLayout> 
</RelativeLayout> 

現在更新在這裏太

mTVTitle = (TextView) findViewById(R.id.tv_title); 
mTVHack = (TextView) findViewById(R.id.hack_txt); 

最後更新過這裏。

.setTarget(new ViewTarget(mTVHack)) 

你完成了快樂編碼。

enter image description here

+0

效果不一樣,圈子只關注中心 –

+0

@BikeshMAnnur然後添加你的佈局和代碼。 –

+0

@BikeshMAnnur檢查更新的答案 –