有谁知道箭头不在TextView中间的原因是什么?
比较它在Android中的显示方式:以及它看起来如何看起来很糟糕
添加它的代码如下所示:
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>