Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to move 20dip margin left from center?

Tags:

android

layout

i want to move a seekbar 20dip margin left from center.

android:progressDrawable="@drawable/progress_vertical"
            android:thumb="@drawable/seek_thumb" android:layout_height="80dip"
            android:layout_width="20dip" android:layout_marginBottom="50dip"
            android:layout_alignParentBottom="true" android:visibility="gone"
            android:layout_centerHorizontal="true" android:layout_marginLeft="20dip" /> 

but the above xml code shows it center only.

like image 802
Archana Avatar asked Oct 03 '11 04:10

Archana


1 Answers

I made a workaround with a TextView in the middle that has no content (and is not visible).

<TextView
        android:id="@+id/viewMiddleInvisible"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/btnAtTheTop"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="30dp" />

<TextView
        android:id="@+id/tvAtLeft"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@id/viewMiddleInvisible"
        android:layout_marginRight="10dp"
        android:layout_toLeftOf="@id/viewMiddleInvisible"
        android:text="Some text" />

You would obviously have to replace tvAtLeft with whatever you want. Same principle if you want to have something to the right of the center.

like image 175
nspo Avatar answered Oct 13 '22 00:10

nspo