Android版的TextView更改文字大小后不调整 [英] Android TextView doesn't resize after changing text size
问题描述
我有一个的ListView
通过该行(图像一些自定义布局,然后用两行文字两个的TextView
垂直的LinearLayout
,见code以下)
我的问题是,当我动态改变文字大小(在适配器
的 getView
法)文字大小会改变,但大小的TextView
一个包装它没有。
下面是当我设置的大小比默认高(图片18),它做什么的图片。尽管有大量的线程或看起来类似的问题,我还没有找到一个解决办法了这一点。
下面是我的列表行布局:
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:方向=横向
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:填充=4DP> < ImageView的机器人:ID =@ + ID / entries_list_item_icon
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginRight =6DP/> <的LinearLayout机器人:方向=垂直
机器人:layout_width =0dip
机器人:layout_weight =1
机器人:layout_height =FILL_PARENT>
< TextView的机器人:ID =@ + ID / entries_list_item_name
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =1
机器人:重力=center_vertical
机器人:文字颜色=@色/ entries_list_item_name/>
< TextView的机器人:ID =@ + ID / entries_list_item_summary
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =1
机器人:单线=真
机器人:ellipsize =金字招牌
机器人:文字颜色=@色/ entries_list_item_summary/>
< / LinearLayout中>< / LinearLayout中>
我试图切换的高度,以 0dip
其他地方一样的建议,它并没有改变任何事情。
修改的的ListView
本身是非常基本的:
< ListView的机器人:ID =@ + ID / entries_list
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT/>
我认为你将不得不改变的ImageView
高度 FILL_PARENT
。 ImageView的是口述布局的高度。
< ImageView的
机器人:ID =@ + ID / entries_list_item_icon
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =FILL_PARENT
机器人:layout_marginRight =6DP/>
I have a ListView
with some custom layout for the row (an image, then two lines of text using two TextView
in a vertical LinearLayout
, see code below)
My problem is that when I dynamically change the text size (in the getView
method of the Adapter
), the text size does change, but the size of the TextView
that wraps it doesn't.
Here is a picture of what it does when I set the size to something "higher" than the default (picture is with 18). Despite the large number of threads or questions that seem similar, I haven't found a solution to that.
Here is the layout of my list row:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="4dp">
<ImageView android:id="@+id/entries_list_item_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="6dp"/>
<LinearLayout android:orientation="vertical"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="fill_parent">
<TextView android:id="@+id/entries_list_item_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:textColor="@color/entries_list_item_name"/>
<TextView android:id="@+id/entries_list_item_summary"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true"
android:ellipsize="marquee"
android:textColor="@color/entries_list_item_summary"/>
</LinearLayout>
</LinearLayout>
I tried switching the heights to 0dip
as suggested elsewhere, it didn't change a thing.
EDIT The ListView
itself is very basic:
<ListView android:id="@+id/entries_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
I think you will have to change imageview
height to fill_parent
. Imageview is dictating the height of your layout.
<ImageView
android:id="@+id/entries_list_item_icon"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginRight="6dp" />
这篇关于Android版的TextView更改文字大小后不调整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!