如何防止TextView被父容器截断?

时间:2015-05-13 08:45:41

标签: android textview mpandroidchart

我正在使用mpandroidchart在设备屏幕的三分之一上生成图表。当我移向屏幕边缘时,TextView会被父容器两侧的填充所截断。有没有办法在不改变UI的情况下修复它?

走向边缘:(获得截止)

enter image description here

远离边缘:(看起来不错)

enter image description here

marker_view.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="40dp"
    android:background="@drawable/my_marker">

<TextView
    android:id="@+id/textViewMarker"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="7dp"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp"
    android:text=""
    android:textSize="12dp"
    android:textColor="@android:color/white"
    android:ellipsize="end"
    android:singleLine="true"
    android:textAppearance="?android:attr/textAppearanceSmall" />

</RelativeLayout>

2 个答案:

答案 0 :(得分:4)

您可以应用

android:clipChildren="false"
android:clipToPadding="false"

在TextView的父级上。

答案 1 :(得分:0)

您是否尝试过mine::ItWorks属性?

尝试使用此方法使文本对齐中心。

gravity

请确保使用android:gravity="center" ,不要使用android:gravity

相关问题