我有什么如果maxLines = 1,为什么字符/剪切TextView中的文本?
我是谁出以 “https://” URL的TextView的前缀:
<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="test2"
android:maxLines="1"
android:ellipsize="marquee"
android:textStyle="bold"
android:textSize="16sp"
android:textColor="@color/primary_text"
android:id="@+id/txvNomEntornIversio" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="https://test2.sdasasdasdfasdfasdffasdfasdfasdf.sdffd"
android:ellipsize="end"
android:maxLines="1"
android:paddingLeft="10dp"
android:textSize="13sp"
android:textStyle="italic"
android:id="@+id/txvUrlEntorn"/>
</LinearLayout>
是什么问题?
结果在Android Studio中预览和装置执行的代码后:
我需要什么
我需要显示的前缀“https://开头”最大字母以适合可用空间。
是我的尝试
我试图read documentation(setEllipsize块)和计算器搜索,搜索与该符号并没有什么发现了一些参考。 我也尝试过无效的符号。
任何人都知道它为什么会发生,并可以帮助我吗?提前致谢!
修订LAYOUT
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="15dp"
android:paddingBottom="15dp"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/icon_unchecked"
android:layout_marginRight="10dp"
android:id="@+id/txvIconChecked"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="test2"
android:maxLines="1"
android:ellipsize="marquee"
android:textStyle="bold"
android:textSize="16sp"
android:textColor="@color/primary_text"
android:id="@+id/txvNomEntornIversio" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="https://mydomain.asdfasdasdfasdfasdffasdfasdfasdf.cat"
android:ellipsize="end"
android:maxLines="1"
android:paddingLeft="10dp"
android:textSize="13sp"
android:textStyle="italic"
android:id="@+id/txvUrlEntorn"/>
</LinearLayout>
</LinearLayout>
UPDATE 2
感谢Teiky,我们发现只有在低于API 23的版本中才会出现此问题。它可能是一个错误?
该选项(不建议使用)Android:SingleLine =“true”似乎在所有版本中都能正常工作!相反,新的选项的android:与Android MAXLINES:ellipsize仅适用于23 ...
目前,最可行的办法似乎忽略已过时SINGLELINE ...
解ME
最后,正如我在上次更新中所述,我的解决方案是继续使用android:SingleLine = true,即使它被标记为已弃用。
帝京秒时,他尝试了dipsositiu的Android 4.4.4,并运作良好使用MAXLINES ellipsize ......和我,一个设备棒棒堂我还是剪切文本找到符号/ ...
集响应Teikyo和它一样好帮助我进一步调查问题。感谢大家的帮助!
在你的行中加入一个额外的/例如'https:///'第一个/ //是一个转义字符 –
感谢Jonathan,我试过这个:“https:///”,结果相同。 ..也试过“https:\/\ /”但没有效果... – jcasadellaoller