gpt4 book ai didi

android - TextView 椭圆大小在 RelativeLayout 中不起作用

转载 作者:太空狗 更新时间:2023-10-29 16:18:57 26 4
gpt4 key购买 nike

我不明白为什么我的 textview 没有被省略。感谢您的帮助。
我有这样的布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="65dp"
android:background="@drawable/dash_whiteplate"
android:minHeight="@dimen/info_activity_list_item_height"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:weightSum="1.0" >

<RelativeLayout style="@style/ItemFlightRouteLayout" >

<ImageView
android:id="@+id/routImageTop"
style="@style/ItemFlightRouteArrow"
android:src="@drawable/icon_arrowup_normal" />

<TextView
android:id="@+id/routAiroportFrom"
style="@style/ItemFlightRouteAirportName"
android:layout_toLeftOf="@+id/topDescription"
android:layout_toRightOf="@+id/routImageTop"
android:textAppearance="@style/ItemFlightRouteAirportName"
android:text="askdjflsfksdfasdfdfsfdsfsdfsfdsdfsfd" />

<RelativeLayout
android:id="@+id/topDescription"
style="@style/ItemFlightRouteDescriptionLayout" >

<View
android:id="@+id/verticalDivider"
style="@style/ItemFlightRouteSeparator"
android:layout_toLeftOf="@+id/txt_time" />

<RelativeLayout
android:id="@+id/txt_time"
android:layout_width="60dp"
android:layout_height="match_parent"
android:layout_toLeftOf="@+id/verticalDivider2" >

<TextView
android:id="@+id/timeDep"
style="@style/ItemFlightRouteText"
android:textColor="@color/statusLanded" />
</RelativeLayout>

<View
android:id="@+id/verticalDivider2"
style="@style/ItemFlightRouteSeparator"
android:layout_toLeftOf="@+id/txt_gate" />

<RelativeLayout
android:id="@+id/txt_gate"
android:layout_width="60dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true" >

<TextView
android:id="@+id/desciptionTop"
style="@style/ItemFlightRouteText" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>

<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="@color/grey" />

<RelativeLayout style="@style/ItemFlightRouteLayout" >

<ImageView
android:id="@+id/routImageBottom"
style="@style/ItemFlightRouteArrow"
android:src="@drawable/icon_arrowdown_normal" />

<TextView
android:id="@+id/routAiroportTo"
style="@style/ItemFlightRouteAirportName"
android:layout_toLeftOf="@+id/bottomDescription"
android:layout_toRightOf="@+id/routImageBottom"
android:textAppearance="@style/ItemFlightRouteAirportName" />

<RelativeLayout
android:id="@+id/bottomDescription"
style="@style/ItemFlightRouteDescriptionLayout" >

<View
android:id="@+id/verticalDivider3"
style="@style/ItemFlightRouteSeparator"
android:layout_toLeftOf="@+id/txt_time2" />

<RelativeLayout
android:id="@+id/txt_time2"
android:layout_width="60dp"
android:layout_height="match_parent"
android:layout_toLeftOf="@+id/verticalDivider4" >

<TextView
android:id="@+id/timeArr"
style="@style/ItemFlightRouteText" />
</RelativeLayout>

<View
android:id="@+id/verticalDivider4"
style="@style/ItemFlightRouteSeparator"
android:layout_toLeftOf="@+id/txt_gate2" />

<RelativeLayout
android:id="@+id/txt_gate2"
android:layout_width="60dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true" >

<TextView
android:id="@+id/desciptionBottom"
style="@style/ItemFlightRouteText" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>

</LinearLayout>

和样式:

<style name="ItemFlightRouteLayout">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_weight">0.5</item>
<item name="android:weightSum">1.0</item>
</style>

<style name="ItemFlightRouteArrow">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_alignParentLeft">true</item>
<item name="android:layout_centerInParent">true</item>
<item name="android:layout_marginLeft">5dp</item>
</style>

<style name="ItemFlightRouteAirportName">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_centerVertical">true</item>
<item name="android:layout_margin">5dp</item>
<item name="android:ellipsize">marquee</item>
<item name="android:padding">2dp</item>
<item name="android:singleLine">true</item>
<item name="android:textColor">@android:color/black</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">14sp</item>
</style>

<style name="ItemFlightRouteDescriptionLayout">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_alignParentRight">true</item>
<item name="android:layout_gravity">right</item>
</style>

<style name="ItemFlightRouteSeparator">
<item name="android:layout_width">1dp</item>
<item name="android:layout_height">22dp</item>
<item name="android:layout_centerVertical">true</item>
<item name="android:layout_marginBottom">5dp</item>
<item name="android:layout_marginTop">5dp</item>
<item name="android:background">@color/grey</item>
</style>

<style name="ItemFlightRouteText">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_centerVertical">true</item>
<item name="android:layout_margin">5dp</item>
<item name="android:gravity">center</item>
</style>

enter image description here

最佳答案

我终于明白了!
我所做的:将 routImageTop 和 routAiroportFrom 移至 LinearLayout,将其与父级左侧对齐并设置 android:layout_toLeftOf="@+id/topDescription"
现在可以了。

关于android - TextView 椭圆大小在 RelativeLayout 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20403663/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com