【完美解决系列】Android在自定义Dialog中TextView内容显示不全的问题

在自定义Dialog中使用了TextView,但是发现内容一直显示不全的问题,代码完全没有问题。经过测试后发现了解决方法,就是在自定义的Dialog中使用TextView组件时,设置Android:layout_width不能使用wrap_content,如:

"@+id/tv_dialog_info"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="left"
        android:text="tv_dialog_info"
        android:textSize="15sp" />

应该改成match_parent,就可以解决此问题了。
代码如:

"@+id/tv_dialog_info"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="left"
        android:text="tv_dialog_info"
        android:textSize="15sp" />

还需要注意的一点是,若你在自定义的Dialog布局中使用了Linearlayout,那么你必须在每个组件中都使用 android:layout_width=”match_parent”,不然的话也会影响布局。

你可能感兴趣的:(解决Android,bug,Android开发技巧,Android开发问题整理)