I'e been experiencing some odd behavior from the text cursor in the EditTexts of my android application. Essentially, the cursor does not always accurately represent it's position in a word (it's all over the place). As such, typing a character into an edit text can result in the character being placed somewhere different (usually before or after the cursor indicated position). Also, when the cursor is placed inside of or next to a word, that word is often offset slightly.
Here is an example of the phenomenon;
Notice the words moving position from picture to picture, and in the second example the cursor indicates that it is before the i but is in fact before the e two indexes to the right.
Here is the EditText element of this View in the XML;
<EditText
android:id="#+id/hazard_obs_text"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="#+id/hazard_observation"
android:layout_alignLeft="#+id/hazard_observation"
android:layout_alignRight="#+id/hazard_observation"
android:layout_above="#+id/finalise_hazard"
android:layout_marginTop="5dp"
android:background="#drawable/whitebackselector"
android:hint="Recommendation Text"
android:textSize="9sp"
android:gravity="start"
android:paddingLeft="5dp"
android:enabled="false"
/>
As you can see, it is inside a RelativeLayout, and has a custom blank white background with some subtle shading around the edge. It is also part of a Fragment layout. Nothing out of the ordinary as far as I can see. No exceptions or errors are being thrown. I am stumped. Does anyone have any ideas what could be causing this odd behavior?
Extra details by request;
The Layout isn't changed programmatically in any way except to be inflated initially (it is in a Fragment after all). Below is any line of code that interacts programmatically with the above example EditText -
obsText = (EditText) fragmentView.findViewById(R.id.hazard_obs_text);
...
obsText.setEnabled(tf); // Where tf is a boolean value.
...
obsText.getText().clear();
...
obsText.setText(observations[0].split(" ", 3)[1]); // Where observations[0] is a string.
...
obsText.setText(currentAssessment.obsDescript); // Setting another string.
Below is the full fragment layout. It is worth noting that I am also having the same issue in a very simple LinearLayout -
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#070054"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<AutoCompleteTextView
android:id="#+id/hazard_code"
android:layout_width="0dp"
android:layout_height="20dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/hazard_code_browse_button"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:gravity="center_vertical"
android:hint="Hazard Code"
android:background="#drawable/whitebackselector"
android:singleLine="true"
android:textSize="12sp"
android:selectAllOnFocus="true"
android:paddingLeft="5dp"
android:dropDownWidth="fill_parent"
android:dropDownHeight="125dp"
android:dropDownVerticalOffset="1dp"
android:completionThreshold="1"
/>
<Button
android:id="#+id/hazard_code_browse_button"
android:layout_width="30dp"
android:layout_height="20dp"
android:layout_toLeftOf="#+id/sfrp_drops"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
android:layout_marginRight="7dp"
android:background="#drawable/crossselector"
/>
<Spinner
android:id="#+id/hazard_observation"
android:layout_width="0dp"
android:layout_height="20dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/sfrp_drops"
android:layout_toLeftOf="#+id/pictures"
android:background="#drawable/whitebackselector"
android:paddingLeft="5dp"
android:dropDownWidth="wrap_content"
android:dropDownHeight="125dp"
android:dropDownVerticalOffset="1dp"
android:enabled="false"
/>
<LinearLayout
android:id="#+id/sfrp_drops"
android:orientation="horizontal"
android:layout_centerHorizontal="true"
android:layout_width="160dp"
android:layout_height="20dp"
android:layout_marginTop="10dp"
android:layout_marginRight="5dp"
>
<Spinner
android:id="#+id/hazard_severity"
android:layout_width="0dp"
android:layout_height="20dp"
android:layout_weight="1"
android:background="#drawable/whitebackselector"
android:prompt="#string/hazard_severity"
android:paddingLeft="5dp"
android:enabled="false"
/>
<Spinner
android:id="#+id/hazard_frequency"
android:layout_width="0dp"
android:layout_height="20dp"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:background="#drawable/whitebackselector"
android:prompt="#string/hazard_frequency"
android:paddingLeft="5dp"
android:enabled="false"
/>
<Spinner
android:id="#+id/hazard_risk"
android:layout_width="0dp"
android:layout_height="20dp"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:background="#drawable/whitebackselector"
android:prompt="#string/hazard_risk"
android:paddingLeft="5dp"
android:enabled="false"
/>
<Spinner
android:id="#+id/hazard_priority"
android:layout_width="0dp"
android:layout_height="20dp"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:background="#drawable/whitebackselector"
android:prompt="#string/hazard_priority"
android:paddingLeft="5dp"
android:enabled="false"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/pictures"
android:orientation="vertical"
android:layout_width="25dp"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_margin="5dp"
android:background="#drawable/photoreel"
>
<ImageView
android:id="#+id/photo_icon"
android:src="#drawable/hal"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
</LinearLayout>
<EditText
android:id="#+id/hazard_obs_text"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="#+id/hazard_observation"
android:layout_alignLeft="#+id/hazard_observation"
android:layout_alignRight="#+id/hazard_observation"
android:layout_above="#+id/finalise_hazard"
android:layout_marginTop="5dp"
android:background="#drawable/whitebackselector"
android:hint="Recommendation Text"
android:textSize="9sp"
android:gravity="start"
android:paddingLeft="5dp"
android:enabled="false"
/>
<EditText
android:id="#+id/hazard_act_text"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="#+id/sfrp_drops"
android:layout_alignLeft="#+id/sfrp_drops"
android:layout_alignRight="#+id/sfrp_drops"
android:layout_above="#+id/finalise_hazard"
android:layout_marginTop="5dp"
android:background="#drawable/whitebackselector"
android:hint="Observation Text"
android:textSize="9sp"
android:gravity="start"
android:paddingLeft="5dp"
android:enabled="false"
/>
<Button
android:id="#+id/finalise_hazard"
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_alignRight="#+id/hazard_obs_text"
android:layout_alignLeft="#+id/hazard_act_text"
android:layout_alignParentBottom="true"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="#drawable/plainbuttonselector"
android:padding="0dp"
android:textColor="#FFFFFF"
android:text="Finalise Entry"
android:enabled="false"
/>
<EditText
android:id="#+id/peoples_at_risk"
android:layout_width="0dp"
android:layout_height="20dp"
android:layout_below="#+id/hazard_location"
android:layout_alignLeft="#+id/hazard_code"
android:layout_toLeftOf="#+id/hazard_act_text"
android:layout_marginTop="5dp"
android:layout_marginRight="7dp"
android:background="#drawable/whitebackselector"
android:textSize="9sp"
android:singleLine="true"
android:paddingLeft="5dp"
android:hint="Peoples at Risk"
android:enabled="false"
/>
<EditText
android:id="#+id/hazard_location"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_below="#+id/hazard_code"
android:layout_alignLeft="#+id/hazard_code"
android:layout_toLeftOf="#+id/hazard_act_text"
android:layout_marginTop="5dp"
android:layout_marginRight="7dp"
android:background="#drawable/whitebackselector"
android:textSize="9sp"
android:paddingLeft="5dp"
android:gravity="start"
android:hint="Hazard Location"
android:enabled="false"
/>
<EditText
android:id="#+id/relevant_legistlation"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="#+id/peoples_at_risk"
android:layout_alignLeft="#+id/hazard_code"
android:layout_toLeftOf="#+id/hazard_act_text"
android:layout_alignParentBottom="true"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_marginRight="7dp"
android:background="#drawable/whitebackselector"
android:textSize="9sp"
android:paddingLeft="5dp"
android:gravity="start"
android:hint="Relevant Legislation"
android:enabled="false"
/>
</RelativeLayout>
I am experiencing the issue on a Nexus 10, Galaxy Note 10.1, & Xperia Z2 tablets with the latest version of Android installed. I've also tested this on an old Xperia phone as well which is not having the issue, which begs the question of whether it could be related to screen size. Other applications on the same devices aren't having this issue.
Any help would be greatly appreciated. This has been hounding me for some time now. I am willing to manually award a bounty to anyone who can help towards a solution/explanation.
I spent a great deal of time trying various bits'n'bobs to solve this issue, but the final change that fixed it entirely was adding a (previously absent) uses-sdk element and it's attributes to the Android Manifest.
<uses-sdk android:minSdkVersion="1" android:targetSdkVersion="4" />
These were the lowest values that could be declared without incurring the problem.
Related
I am creating one Layout and in that I am putting divider via View. But Both Divider is not looking same. which have all property same.
Take a close look at screenshot :
The First one looked well as I want. But the second one is thin as you can close look.
Code :
<TextView
android:id="#+id/txt_security_currentRole"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="#dimen/normal_margin8"
android:text="#string/security_current_role"
android:textColor="#DE000000"
android:fontFamily="sans-serif"
android:textSize="#dimen/textsize14" />
<View
android:id="#+id/view_currentRole"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/txt_security_currentRole"
android:background="#61000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/view_currentRole"
android:layout_marginLeft="#dimen/normal_margin8"
android:paddingBottom="#dimen/normal_margin8"
android:paddingTop="#dimen/normal_margin5"
android:text="#string/security_user"
android:textColor="#8A000000"
android:fontFamily="sans-serif"
android:textSize="#dimen/textsize14" />
<TextView
android:id="#+id/txt_upgraderole"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/view_currentRole"
android:paddingTop="#dimen/normal_margin8"
android:text="#string/security_upgrade_role"
android:textColor="#color/colorPrimary"
android:textSize="#dimen/textsize14"
android:textStyle="italic"
android:fontFamily="sans-serif" />
<TextView
android:id="#+id/txt_viewpassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_upgraderole"
android:paddingBottom="#dimen/normal_margin8"
android:text="#string/password"
android:textColor="#DE000000"
android:fontFamily="sans-serif"
android:textSize="#dimen/textsize14" />
<View
android:id="#+id/view_password"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/txt_viewpassword"
android:background="#61000000" />
If any one know what about that it can tell me.
Any Help be Highly Appreciated.
You can create a separate layout with the view you want and include it in the places where ever you need...I think this solution would help you...
I am agree with #Ironman that Textview is for displaying Text. You can check this:
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="?android:attr/listDivider"/>
Try using Textview instead of View. Using textview gives same divider as view.
<TextView
android:id="#+id/txt_security_currentRole"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="#dimen/normal_margin8"
android:text="#string/security_current_role"
android:textColor="#DE000000"
android:fontFamily="sans-serif"
android:textSize="#dimen/textsize14" />
<TextView
android:id="#+id/view_currentRole"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/txt_security_currentRole"
android:background="#61000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/view_currentRole"
android:layout_marginLeft="#dimen/normal_margin8"
android:paddingBottom="#dimen/normal_margin8"
android:paddingTop="#dimen/normal_margin5"
android:text="#string/security_user"
android:textColor="#8A000000"
android:fontFamily="sans-serif"
android:textSize="#dimen/textsize14" />
<TextView
android:id="#+id/txt_upgraderole"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/view_currentRole"
android:paddingTop="#dimen/normal_margin8"
android:text="#string/security_upgrade_role"
android:textColor="#color/colorPrimary"
android:textSize="#dimen/textsize14"
android:textStyle="italic"
android:fontFamily="sans-serif" />
<TextView
android:id="#+id/txt_viewpassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_upgraderole"
android:paddingBottom="#dimen/normal_margin8"
android:text="#string/password"
android:textColor="#DE000000"
android:fontFamily="sans-serif"
android:textSize="#dimen/textsize14" />
<TextView
android:id="#+id/view_password"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/txt_viewpassword"
android:background="#61000000" />
I've just replaced <View> by <Textview>
After lots of try like
1. Clean the Project and Rebuild it
2. Restart The Studio.
3. Restart the whole System
nothing is work well.
Finally Uninstall the App and reinstall is work for me.
I have debugged and everything goes fine; moreover, in Graphical Layout everything is fine. here you can see the code:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:background="#color/white" >
<ImageView
android:id="#+id/image"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginStart="5dp"
android:src="#drawable/news_img1" />
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_alignParentTop="true"
android:layout_toEndOf="#id/image"
android:text="Pizza Rondon"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/title"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:layout_toEndOf="#id/image"
android:text="Ingredients: meat, potato, tomato, salad included too. " />
<TextView
android:id="#+id/price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginEnd="20dp"
android:text="60 Lei"
android:textColor="#color/dimmed_red"
android:textStyle="bold" />
</RelativeLayout>
and here is the result as this view is an item from ExpandableListView:
I dont set any data to TextViews inside my customAdapter. What could cause the TextViews to dissapear? I can't even see any difference between price and others two which are not shown, which do not differ much in layout.
Did you try changing text color - maybe it is set to white??? The price is showing because android:textColor="#color/dimmed_red"
I'm trying to display information to the user through the use of a RelativeLayout but when I use layout_marginTop or paddingTop to create some spacing betweem my items the item below won't take in into account and they will both start overlapping.
Here are a few pics to help understand my problem :
Initial situation:
Adding a android:marginTop="48dip" to the TextView to better illustrate the problem:
I also tried adding the same android:marginTop="48dip" to the EditText but the result was unexpected too. (Link to the screenshot can be find in the comment as a user with less than 10 reputation can't post more than 2 links)
The Layout I'm using (simplified version)
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout xmlns:local="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="8dp">
<!--Identification part-->
<TextView
android:id="#+id/idPartTV"
android:text="Site"
android:textColor="#FFFFFF"
android:textSize="20sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<View
android:id="#+id/idPartLine"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_below="#id/idPartTV"
android:layout_marginTop="4dip"
android:background="#android:color/darker_gray" />
<!--Site name-->
<TextView
android:id="#+id/siteNameTV"
android:text="Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/idPartLine"
android:layout_marginTop="8dip" />
<EditText
android:id="#+id/siteName"
local:MvxBind="Text Name"
android:layout_below="#id/idPartLine"
android:layout_toRightOf="#+id/transTV"
android:layout_alignBaseline="#id/siteNameTV"
android:layout_width="wrap_content"
android:layout_height="48dip" />
<!--Site ID-->
<TextView
android:id="#+id/siteIdTV"
android:text="ID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/siteName" />
<EditText
android:id="#+id/siteID"
local:MvxBind="Text Id"
android:layout_width="wrap_content"
android:layout_height="48dip"
android:layout_below="#id/siteName"
android:layout_toRightOf="#id/transTV"
android:layout_alignBaseline="#id/siteIdTV" />
<!--location Part-->
<TextView
android:id="#+id/locPartTV"
android:text="Location"
android:textColor="#FFFFFF"
android:textSize="20sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/siteID" />
<View
android:id="#+id/locPartLine"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_below="#id/locPartTV"
android:background="#android:color/darker_gray"
android:layout_marginTop="4dip" />
<!--Latitude-->
<TextView
android:id="#+id/latTV"
android:text="Latitude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/locPartLine" />
<EditText
android:id="#+id/latitude"
local:MvxBind="Text Latitude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/locPartLine"
android:layout_toRightOf="#id/transTV"
android:layout_alignBaseline="#id/latTV"
android:inputType="numberDecimal" />
<!--Longitude-->
<TextView
android:id="#+id/longTV"
android:text="Longitude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/latitude" />
<EditText
android:id="#+id/longitude"
local:MvxBind="Text Longitude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/latitude"
android:layout_toRightOf="#id/transTV"
android:layout_alignBaseline="#id/longTV"
android:inputType="numberDecimal" />
</RelativeLayout>
</ScrollView>
In the snippet of code above, transTV is my largest TextView. I'm using it to be sure that all the EditText will be vertically aligned. SiteID is another EditText that is situated above the one presented here. As I had a lot of them I mutilated my code to avoid redundancies.
In my idea of the android:marginTop and of the RelativeLayout, adding some space between the latitude and the separating line should be taken into account to calculate the position of the longitude as it is set to be below the latitude using android:layout_below.
I want to display three different values allocated to two different headers, in other words a first header with one value and a second one with two values
My approach is to split the "header linear layout" 40/60 and the "values linear layout" 40/30/30. In order to not display the text beginning at the border, I put everywhere an android:layout_marginLeft="15dp" in, so finally it should remain proportional.
In my XML, I declare the following:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_weight="4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:text="#string/txt_price_chf"
/>
<TextView
android:layout_weight="6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:text="#string/txt_price_offshore_chf"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView android:id="#+id/tv_price_ch"
android:layout_weight="4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:text="Value1"
/>
<TextView android:id="#+id/tv_price_off_chf"
android:layout_weight="3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:text="Value2"
/>
<TextView android:id="#+id/tv_price_off_eur"
android:layout_weight="3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:text="Value3"
/>
</LinearLayout>
The result is following output:
Why are the "Price offshore:"-TextView and the "Value2"-TextView not in line? Note that "Price offshore" is saved in my strings.xml, there is no error like a whitespace or something. First I thought, it's caused by the android:layout_marginLeft="15dp", but
how I understood it the "dp" is a relative value to a specific
resolution (so the split-off by android:layout_weigth should not
effect this) and
if I remove the margins, they are still not in
line.
Has anyone an idea? Do I overlook something obvious?
<TextView
android:layout_weight="4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="-10dp"
android:text="#string/txt_price_chf"
/>
This will work for you...
Not really something you should be doing with a LinearLayout though.
I suggest using a RelativeLayout, there you can just say that those two should align.
Without digging into details in this particular case, it can be either marginRight, padding etc or just simply a side effect of the non monospaced font.
Or another alternative is this:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight=".60"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="txt_price_chf" />
<TextView
android:id="#+id/tv_price_ch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Value1" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight=".40"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="txt_price_offshore_chf" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/tv_price_off_chf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Value2" />
<TextView
android:id="#+id/tv_price_off_eur"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Value3" />
</LinearLayout>
</LinearLayout>
Here are sample pictures of two EditText fields I've added in an Action Bar:
[This is from the Graphical Layout tool in Eclipse]
[This is what it looks like in my emulator (2.1 WVGA854)
My question is, how can I make the EditText look a bit closer to the Graphical Layout? Or is this a function of the emulation? On my device, which has a custom rom, the EditText is square but looks similar to the Graphical Layout, which is what I want.
I've tried setting the textAppearance to "#android:attr/textAppearanceSmall". This does help in that it changes the size of the text within the EditText to be viewable, but it does not affect the size of the EditText itself.
Here's the XML for my EditText:
<EditText
android:maxLines="1"
android:scrollHorizontally="true"
android:textAppearance="#android:attr/textAppearanceSmall"
android:layout_marginTop="5dip"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
I could post the full XML, but essentially this EditText is enclosed (along with the search icon ImageView) in a RelativeLayout that is within another RelativeLayout.
Thanks for any help!
EDIT
By request, here is the full XML for the top search bar:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageButton
android:id="#+id/IBSearchOverlayMic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#drawable/aslctr_search_overlay_blackbutton"
android:src="#drawable/search_overlay_ic_microphone" />
<ImageView
android:id="#+id/IVSearchOverlayDivider1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/IBSearchOverlayMic"
android:src="#drawable/search_overlay_division" />
<ImageButton
android:id="#+id/IBSearchOverlaySearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/IVSearchOverlayDivider1"
android:background="#drawable/aslctr_search_overlay_blackbutton"
android:src="#drawable/search_overlay_ic_searchwhite" />
<RelativeLayout
android:id="#+id/RLSearchOverlaySearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#id/IBSearchOverlaySearch"
android:layout_alignBottom="#id/IBSearchOverlaySearch"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#id/IBSearchOverlaySearch"
android:layout_centerVertical="true"
android:background="#drawable/search_overlay_searchbg">
<EditText
android:id="#+id/ETSearchOverlaySearch"
android:maxLines="1"
android:scrollHorizontally="true"
android:textAppearance="#android:attr/textAppearanceSmall"
android:layout_marginTop="5dip"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#id/ETSearchOverlaySearch"
android:layout_centerVertical="true"
android:layout_marginRight="10dip"
android:clickable="false"
android:focusable="false"
android:src="#drawable/search_actionbar_ic_searchcream" />
</RelativeLayout>
</RelativeLayout>
I determined the problem. The issue was that the EditText was inside the RelativeLayout...I think that messed with the padding, or perhaps the EditText's layout_height="wrap_content" meant that it extended vertically. Here's the reworked XML:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageButton
android:id="#+id/IBSearchOverlayMic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#drawable/aslctr_search_overlay_blackbutton"
android:src="#drawable/search_overlay_ic_microphone" />
<ImageView
android:id="#+id/IVSearchOverlayDivider1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/IBSearchOverlayMic"
android:src="#drawable/search_overlay_division" />
<ImageButton
android:id="#+id/IBSearchOverlaySearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/IVSearchOverlayDivider1"
android:background="#drawable/aslctr_search_overlay_blackbutton"
android:src="#drawable/search_overlay_ic_searchwhite" />
<ImageView
android:id="#+id/IVSearchBackground"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#id/IBSearchOverlaySearch"
android:layout_alignBottom="#id/IBSearchOverlaySearch"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#id/IBSearchOverlaySearch"
android:layout_centerVertical="true"
android:background="#drawable/search_overlay_searchbg" />
<EditText
android:id="#+id/ETSearchOverlaySearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#id/IBSearchOverlaySearch"
android:layout_alignBottom="#id/IBSearchOverlaySearch"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#id/IBSearchOverlaySearch"
android:layout_marginTop="5dip"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginBottom="0dip"
android:paddingBottom="0dip"
android:maxLines="1"
android:scrollHorizontally="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/IBSearchOverlaySearch"
android:layout_alignTop="#id/IBSearchOverlaySearch"
android:layout_alignBottom="#id/IBSearchOverlaySearch"
android:layout_centerVertical="true"
android:layout_marginRight="15dip"
android:clickable="false"
android:focusable="false"
android:src="#drawable/search_actionbar_ic_searchcream" />
</RelativeLayout>