Create divider View not display well in android - android

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.

Related

Android studio - Relative layout misplaced items after run on phisical device

Hope you can help me with my question, I have three TextViews and a sepparator, on my relative layout, on the designer I have aranged them , but after I run it on a phisical device , only one item appear and even that item is misplaced. I have to tell you that i have searched for many many hours before coming here to ask this question, so please help me!
Here it is the XML file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="44dp"
android:paddingTop="24dp"
tools:ignore="RtlSymmetry">
<TextView
android:id="#+id/tv_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignStart="#+id/tv_today_date"
android:gravity="end|center_vertical"
android:paddingEnd="16dp"
android:textAlignment="center"
android:textSize="56sp"
android:visibility="visible"
tools:text="12:34" />
<TextView
android:id="#+id/tv_today_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:paddingEnd="16dp"
android:text="Tue, 20 Apr"
android:textSize="16sp"
android:layout_below="#+id/tv_today_time"
android:layout_toStartOf="#+id/separator" />
<View
android:id="#+id/separator"
android:layout_width="0.05dp"
android:layout_height="0.05dp"
android:layout_alignBottom="#+id/tv_today_date"
android:layout_alignTop="#+id/tv_today_time"
android:layout_centerHorizontal="true"
android:background="#66FFFFFF" />
<TextView
android:id="#+id/tv_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="start"
android:paddingStart="16dp"
android:textSize="16sp"
tools:text="Bucharest"
android:layout_below="#+id/tv_today_time"
android:layout_toEndOf="#+id/separator" />
If needed, i will post some screenshots.
Also I have also some other questions, so if anyone wants to help me, tell me :)
EDIT
Here iis what I would like it to be:Designer
Here is what i get:Phisical device
Option 1: Use constraint layout (Material design)
Option 2: Wrap tv_today_date separator & tv_location in LinearLayout with horizontal orientation. Place this LinearLayout below tv_time
This is working fine for me.Check it and let me know.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="24dp"
>
<TextView
android:id="#+id/tv_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:gravity="end|center_vertical"
android:paddingRight="16dp"
android:textAlignment="center"
android:textSize="56sp"
android:visibility="visible"
android:text="12:34" />
<View
android:id="#+id/separator"
android:layout_width="0.05dp"
android:layout_height="0.05dp"
android:layout_alignBottom="#+id/tv_today_date"
android:layout_alignTop="#id/tv_time"
android:layout_centerHorizontal="true"
android:background="#66FFFFFF" />
<TextView
android:id="#+id/tv_today_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:paddingRight="16dp"
android:text="Tue, 20 Apr"
android:textSize="16sp"
android:layout_below="#id/tv_time"
android:layout_toLeftOf="#id/separator" />
<TextView
android:id="#+id/tv_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="start"
android:paddingLeft="16dp"
android:textSize="16sp"
android:text="Bucharest"
android:layout_below="#id/tv_time"
android:layout_toRightOf="#id/separator" />
</RelativeLayout>

Android TextView not shown

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"

Introducing marginTop in RelativeLayout creates overlapping

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.

EditText Cursor Positioning Inaccuracies

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.

Android Text View - Top and Bottom edges clipped off

Somebody can please explain this?
Why the third TextView is weird?
The definitions for the 2 lines before are the same, and I haven't touched the style with java...
Edit: I've added the XML Layout file.
The XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/rl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top" >
<TextView
android:id="#+id/quadEqu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="25dp"
android:text="#string/quadequ"
android:textSize="27sp" />
<Button
android:id="#+id/closeBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="30dp"
android:text="#string/close"
android:onClick="close" />
<TextView
android:id="#+id/stepOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/quadEqu"
android:layout_centerHorizontal="true"
android:layout_marginTop="25dp"
android:text="#string/quadEquForm"
android:textSize="18sp" />
<TextView
android:id="#+id/stepTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/stepOne"
android:layout_below="#+id/stepOne"
android:text="#string/quadEquForm"
android:textSize="18sp" />
<TextView
android:id="#+id/stepThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/stepOne"
android:layout_below="#+id/stepTwo"
android:text="#string/quadEquForm"
android:textSize="18sp" />
</RelativeLayout>
It's a strange behaviour.
Try to set the content of the 'stepTwo' to the 'stepThree'.
If the same issue appeared, so the problem from the TextView.
You should check if you modify the padding of 'stepThree' textView programmatically.
In android Text View, when you try to render the subscript, the text gets clipped at the top and bottom. To avoid this, you can try to set the text from HTML.
Example.
stepThree.setText(Html.fromHtml("Some text<sup><small>1</small></sup>"));
stepThree.setText(Html.fromHtml(
"HCO<sub><small><small>3</small></small></sub>));
Refer this link for more details.
Android TextView's subscript being clipped off
Subscript and Superscript a String in Android
You need to change android:layout_height for the TextView (for all 3 is better).
<TextView
android:id="#+id/stepOne"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_below="#+id/quadEqu"
android:layout_centerHorizontal="true"
android:layout_marginTop="25dp"
android:text="#string/quadEquForm"
android:textSize="18sp" />
<TextView
android:id="#+id/stepTwo"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignLeft="#+id/stepOne"
android:layout_below="#+id/stepOne"
android:text="#string/quadEquForm"
android:textSize="18sp" />
<TextView
android:id="#+id/stepThree"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignLeft="#+id/stepOne"
android:layout_below="#+id/stepTwo"
android:text="#string/quadEquForm"
android:textSize="18sp" />

Categories

Resources