android how to make Tooltip for TextView

2019-02-17 15:20发布

问题:

I have a ListView in my activity. which consists of no of textviews. I performed a drag n drop action on textviews. So i want when i drag one item then the item above & below of it should be higlighted as Tooltip. How can I do it. Please give me answer Thanx

回答1:

Here is a good example for using tool tip in android application http://www.londatiga.net/it/how-to-create-quickaction-dialog-in-android/



回答2:

you can draw a drawable with the below code and name it as tooltip.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="2dp" android:left="0dp" android:height="25dp" android:width="30dp">

<shape android:shape="rectangle">
    <solid android:color="@color/seekbar_color">
    </solid>
    <corners android:radius="4dp"></corners>
</shape>
</item>
<item android:left="7.5dp" android:height="15dp" android:width="15dp">

    <rotate
        android:fromDegrees="45"
        android:toDegrees="45">
        <shape
            android:shape="rectangle" >
            <solid
                android:color="@color/seekbar_color" />
        </shape>
    </rotate>
</item>

It will look something like this

You can further use it in a textview as a background

  <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/tooltip"
        android:text="0.5x"
        android:padding="4dp"
        android:gravity="center"
        android:textSize="12sp"
        android:onClick="SaveSpeedMainClick"
        android:id="@+id/textview_activitysave_speed_segment_main"
        android:textColor="@color/white"/>