Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android how to make Tooltip for TextView

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

like image 399
Jyosna Avatar asked May 18 '11 04:05

Jyosna


1 Answers

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 enter image description here

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"/>
like image 141
Nitin Agarwal Avatar answered Oct 19 '22 01:10

Nitin Agarwal