嗨,我有一个可变宽度的Textview,但最大为250dp。但不知何故,Android将其设置为最大。Android TexxtView最大宽度
使用较短的文本和没有最大宽度的作品,但是文本足够长,字段超出屏幕宽度,它与箭头重叠。
我已经尝试过这两个变种,这给了相同的结果画面
<TextView
android:id="@+id/bubbleText"
style="@style/MarkerText"
android:maxWidth="250dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#FF0000"
android:layout_marginEnd="@dimen/defaultSpacing" />
<TextView
android:id="@+id/bubbleText"
style="@style/MarkerText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/defaultSpacing"
android:layout_weight="1"
android:background="#FF0000"
android:maxWidth="250dp"
android:singleLine="false" />
我想,它看起来像这样:
附加infos
完整的XML
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/marker_text_background" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="@dimen/tinySpacing"
android:paddingEnd="@dimen/defaultSpacing"
android:paddingStart="@dimen/defaultSpacing"
android:paddingTop="@dimen/tinySpacing" >
<TextView
android:id="@+id/bubbleText"
style="@style/MarkerText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/defaultSpacing"
android:background="#FF0000"
android:maxWidth="250dp" />
<mypackage.IconTextView
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/MarkerTextIcon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/icon_map_arrow" />
</LinearLayout>
</LinearLayout>
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginBottom="-5dp"
android:layout_marginTop="-1dp"
android:src="@drawable/marker_text_background_rectangle" />
</LinearLayout>
<style name="MarkerText" parent="android:Widget.Holo.Light.TextView">
<item name="android:textColor">@color/myWhite</item>
<item name="android:textSize">@dimen/markerTextSize</item>
</style>
<dimen name="markerTextSize">22sp</dimen>
问题occours个罐独立片段,太
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#FF0000"
android:maxWidth="250dp"
android:text="1. Willkommen bei meiner APP"
android:textSize="22sp" />
什么是style =“@ style/MarkerText”? – Andy 2015-02-06 11:51:31
你不能缩小你的字体大小吗? – 2015-02-06 11:56:06
@MSGadag的字体大小应该无关紧要。如果内容超过最大宽度,它应该仍然包装 – 2015-02-06 11:59:19