【发布时间】:2012-02-22 08:45:13
【问题描述】:
我有一个自定义微调器,它使用两个自定义视图,一个用于下拉菜单,一个用于当前选定的项目。
我的问题是,当前选定项目的自定义视图始终至少与微调器列表中最长的项目一样宽,并且它在我的自定义视图左侧留下了相当大的间隙。如果我从微调器中选择最长的项目,差距就会消失。我已经为我的自定义视图尝试了 android:gravity="left" 。另请注意,这似乎只是 Android 3.0+ 的问题。
这是我的自定义微调器视图的代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/folder_detail" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_width="wrap_content">
<TextView android:text="Folder Name"
android:id="@+id/folder_name" android:textColor="#ffffff"
android:layout_width="wrap_content" android:textSize="16sp"
android:textStyle="bold"
android:layout_height="wrap_content" android:layout_marginTop="0dp">
</TextView>
<TextView android:id="@+id/folder_count" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="13sp" android:text="(0) " android:textColor="@color/light_blue" android:layout_marginLeft="2dp"/>
<ImageView android:id="@+id/icon" android:src="@android:drawable/arrow_down_float"
android:layout_marginRight="1dp" android:scaleType="fitXY"
android:layout_gravity="bottom" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
</LinearLayout>
【问题讨论】:
标签: android android-layout spinner android-custom-view android-spinner