【发布时间】:2014-07-07 12:28:02
【问题描述】:
我试图显示一个 ListView(实际上是一个 DragSortListView),它带有一个类似于 iOS 披露指示器的 textitem 和一个 drawableRight。我无法将 drawableRight 定位到屏幕边缘,它似乎总是出现在文本的末尾而不是屏幕边缘。
例如,这就是我想要的。
+ Text1 here >
+ Text2 >
但它显示为
+ Text1 here>
+ Text2>
我尝试了许多布局选项和建议(因为我的 LinearLayout 是水平的),但它们似乎都没有帮助。我可以做我想做的唯一方法是将 TextView 的 layout_width 设置为一些硬编码值,例如 128dp 以便它显示在屏幕的末尾,但这可能不是一个正确的解决方案,因为屏幕尺寸可能会有所不同。
你能看看我的布局代码,看看我可能缺少什么。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="@drawable/titleslist_selector_tablet"
android:orientation="horizontal"
tools:ignore="HardcodedText,UselessParent">
<ImageView
android:id="@+id/dragHandle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="@android:color/transparent"
android:src="@drawable/dragicon"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:clickable="false"
android:layout_weight="0" />
<TextView
android:id="@+id/listText"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:drawableRight="@drawable/navigate"
android:gravity="left|center"
android:paddingBottom="1dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#454545"
android:layout_weight="1"/>
</LinearLayout>
@drawable/navigate 是显示“>”的图像
【问题讨论】:
-
您是否尝试从您的
ImageView和TextView中删除您的android:weight属性? -
@G.T.是的,我做到了,但运气不好。