Reputation: 564
Can I change "hint" and text position (to rise it to the center)
My xml as follows:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layoutTopBlue"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:background="#4285F4"
android:layout_below="@id/layoutTopBlack"
>
<EditText
android:id="@+id/editText1"
android:layout_gravity="center"
android:text=''
android:hint="my hint"
android:textColorHint="#FFFFFF"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:background="@drawable/edit"
/>
<ImageView
android:id="@+id/imageView1"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_centerVertical="true"
android:layout_alignLeft="@+id/editText1"
android:src="@drawable/search"
/>
<ImageView
android:id="@+id/imageView1"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_centerVertical="true"
android:layout_alignRight="@+id/editText1"
android:src="@drawable/cross"
/>
</RelativeLayout>
Or maybe it is possible to do something with drawable editText:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape >
<solid android:color="@color/editBorder" />
</shape>
</item>
<!-- main color -->
<item android:bottom="1.5dp"
android:left="1.5dp"
android:right="1.5dp">
<shape >
<solid android:color="@color/editBackground" />
</shape>
</item>
<!-- draw another block to cut-off the left and right bars -->
<item android:bottom="5.0dp">
<shape >
<solid android:color="@color/editBackground" />
</shape>
</item>
</layer-list>
Any ideas please? Thanks!
Upvotes: 2
Views: 6280
Reputation: 182
If you need to change the position of edit text. In Graphical layout :- place the cursor in text(hint) and right click ,Layout height -> other -> then set the custom layout attribute value( example :50dp) I think this will work .To rise it in center you can change this value to 30dp or 50dp. or Change this line in Edit text :-
android:layout_height="wrap_content" to android:layout_height="50dp"
Upvotes: 0
Reputation: 715
1) hind text in left of the edittext
<EditText
android:gravity="left"
/>
2) hind text in center of the edittext
<EditText
android:gravity="center"
/>
3) hind text in right of the edittext
<EditText
android:gravity="right"
/>
Upvotes: 3
Reputation: 3339
anyone can use
android:gravity="center|center_horizontal|center_vertical|top"
Upvotes: 4