This question already has answers here:
Why android gives warning on using size smaller than 12sp?
(2 answers)
Closed 4 years ago.
How can I ignore the "Text size is too small" warning in Android Studio?
For example, in one of my TextViews:
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="3"
android:singleLine="false"
android:text="#string/navtask_btn_arrived"
android:textAlignment="center"
android:textSize="8sp"
tools:ignore="textSize"/>
I tried to add:
tools:ignore="textSize"
tools:ignore="TextSize"
tools:ignore="SpUsage"
tools:ignore="spUsage"
tools:ignore="dimen"
It is supposed to work with "textSize", as the documentation mentions it can be used with any attribute.
I know some of these do not make any sense, but hey, why not try them out before asking here?
Any ideas?
You need to add attribute tools:ignore="SmallSp" to remove the warning use SmallSp where SmallSp mean small scalable pixels as
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="3"
android:singleLine="false"
android:text="#string/navtask_btn_arrived"
android:textAlignment="center"
android:textSize="8sp"
tools:ignore="SmallSp"/>
Android Studio gives error:
Avoid using sizes smaller then 12sp.So try to avoid using below 12sp size.
If you still want to use then declare below the line.
tools:ignore="SmallSp"
Minimum text size is 12sp in android
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="3"
android:singleLine="false"
android:text="#string/navtask_btn_arrived"
android:textAlignment="center"
android:textSize="12sp"
tools:ignore="textSize"/>
Related
I have edittext view in my application but when i insert long text in edit text this increases view size.I do not want happened in my app because it created bad imapact on app so I decided to use
android:singleLine="true"
android:ellipsize="end"
android:maxLine="1"
xml attribute to the edit text but it not worked for me .I don't have any idea how to prevent this from my problem.I did lot of R&D but i am not get satisfactory answer.Here is my Edit Text.
<EditText
android:id="#+id/etaccountholdersname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tvaccountholdername"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:background="#drawable/ic_input_field"
android:hint="Account holder's name"
android:singleLine="true"
/>
Here Is full code of Xml file
<RelativeLayout
android:id="#+id/innerrel1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" >
<TextView
android:id="#+id/tvaccountholdername"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#drawable/ic_account_holders_name_text"
android:gravity="left" />
<EditText
android:id="#+id/etaccountholdersname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tvaccountholdername"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:background="#drawable/ic_input_field"
android:hint="Account holder's name"
android:singleLine="true"
android:scrollbars="vertical" />
</RelativeLayout>
Please provide some help me to solve this issues.
In your layout design you have "wrap_content" for both parent and children views. Make the parent layout width as static. If you working with multiple screens, use the dimens.xml for the sizes of the views in different screen sizes.
Use either android:layout_weight property or use android:ems="7" it will work for you definetely
do not use
android:ellipsize="end"
its uses for textview
use
android:ems="10" (it limits edittext to show 10 charecters but you can insert many characters)
and you are good to go.
I'm trying out new things (well, im also new to xml and android). This thing came up to my mind during my brain storming. Is it possible to reference an XML element attribute for a value of an element?
(sorry the english isn't quite well)
idea :
<SeekBar
android:id="#+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView1"
android:layout_below="#+id/textView3"
android:layout_marginLeft="15dp"
android:layout_marginTop="12dp"
android:layout_toRightOf="#+id/textView4"
android:max="9"
android:progress="0" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView5"
android:layout_toRightOf="#+id/seekBar1"
**android:text="#id/seekBar1/progress"**
android:textAppearance="?android:attr/textAppearanceSmall" />
the highlighted part. Thanks for reading and for possible answers
Simple answer: No, unfortunately it's not.
And even if it worked, there were two additional issues:
It seems you would expect the TextView to be updated when the SeekBar progresses, which would not work even if the reference would work.
The system had to automatically convert the progress (a float) to a String.
The layouts in my application are built using SDK 16 and I've tested and confirmed they work fine on ICS and JB but GB has the following issue:
In the code below, I'm just trying to create a simple layout with only text. The text keeps getting cut off on Gingerbread at the end of the first line though, instead of going on to the next line. I've tried setting singeLine to false, played around with lines, maxLines, marquee, layoutWeight, changing layoutHeight and layoutWidth to every imaginable combination, etc. This issue truly baffles me.
Code:-
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text keeps overflowing"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#33B5E5"
android:paddingTop="6dp"
/>
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text gets cut off when I input a long string like this one"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF"
/>
</LinearLayout>
</ScrollView>
Also, if I change the theme of the layout to Gingerbread, I get the error:
Failed to find style 'scrollViewStyle' in current theme
Failed to find style 'textViewStyle' in current theme
android.content.res.Resources$NotFoundException
Thanks in advance.
Fixed it myself. Couldn't find out why it was happening but I fixed it by adding the following lines to the code for TextViews:-
android:ellipsize="none"
android:maxLines="10"
android:scrollHorizontally="false"
This question already has answers here:
android ellipsize multiline textview
(23 answers)
Closed 9 years ago.
How can I make a multiline TextView that truncates the text properly? My TextView is part of a TableRow, so its width is a weight. The following does not work. The result is simply truncated text without the ellipses. I'm using API 10 (Android 2.3.3).
<TextView
android:id="#+id/name_recipe"
android:layout_centerHorizontal="true"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="8"
android:text="Fried pork with mushrooms and potatoes and cilantro"
android:ellipsize="end"
android:maxLines="2"
android:paddingLeft="10dp" />
Reducing the two lines to a single line with the following does work, but it's not ideal:
android:singleLine="true"
I don't like this for two reasons:
android:singleLine is deprecated
I'd much prefer to have the text be on two lines than one.
I've seen discussion about this like from here but I'm hoping a new solution has been found by now.
Try this, it's from my project and works on phone but unfortunately not on tablet emulator:
<TextView
android:id="#+id/myItem"
android:layout_gravity="bottom|center_vertical"
android:textSize="10sp"
android:maxLines="2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:ellipsize="end"
android:lines="2" />
Use lines="1" as all the other methods are deprecated. As well as set scrollHorizontally.
<TextView
android:id="#+id/myid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:scrollHorizontally="true"
android:ellipsize="end"
android:layout_weight="1"
/>
I am currently writing an App for Android and in one of the layouts I have a users name and beside it a couple of tags.
If both the users name and the tags are short enough, they fit neatly into one line. However, when either of the two are longer I want the name to stay fixed to the left, and the tags to drop to a line below and align to the right.
Currently I have the following code:
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="#+id/name"
android:textColor="#000000"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:singleLine="true"
android:id="#+id/tags"
android:textColor="#000000"
android:layout_toRightOf="#+id/name"
android:layout_alignTop="#+id/name"
android:textAppearance="?android:attr/textAppearanceSmall" />
This just simply displays both on one line. I presume I'll need to do the text wrapping in the java or is there a neat XML solution?
As far as I know, there is no XML solution for this problem.
You need to calculate the size of the name and then adjust the tag on the new line or keep it at same line.