箭头符号定位太低

时间:2017-06-22 09:19:20

标签: android textview

有谁知道箭头不在TextView中间的原因是什么?

比较它在Android中的显示方式:enter image description here以及它看起来如何看起来很糟糕enter image description here

添加它的代码如下所示:

for (Ticket ticket : tickets) {
            TextView tvDestination = new TextView(ctx);
            tvDestination.setTextAppearance(ctx, R.style.purchase_row_title);
            tvDestination.setText(ticket.getDepartureStationName() + getDirection(ticket.getTicketType()) + ticket.getArrivalStationName() + " / " + ticket.getDepartureDate());
            tvDestination.setCompoundDrawablesWithIntrinsicBounds(R.drawable.icon_ticket, 0, 0, 0);
            tvDestination.setCompoundDrawablePadding(24);
            tvDestination.setEllipsize(TextUtils.TruncateAt.END);
            tvDestination.setMaxLines(1);
            h.rlDestinations.addView(tvDestination, 0);
        }

风格是:

<style name="purchase_row_title">
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:drawablePadding">10dp</item>
    <item name="android:drawableStart">@drawable/icon_ticket</item>
    <item name="android:maxLines">1</item>
    <item name="android:singleLine">true</item>
    <item name="android:ellipsize">end</item>
    <item name="android:paddingEnd">10dp</item>
    <item name="android:textColor">#242528</item>
    <item name="android:textSize">17sp</item>
    <item name="android:textStyle">bold</item>
</style>

1 个答案:

答案 0 :(得分:0)

实际上箭头位于中间。您应该this发布并了解TextView

Ascent Descent