[英]Android: ListView divider is transparent
Hey i have a listview filled with "custom" TextViews (just added a mehtod for convenience) 嘿,我有一个用“自定义” TextViews填充的列表视图(为方便起见只添加了一个方法)
mRootView = inflater.inflate(R.layout.fragment_session_list, container, false);
mLV = (ListView) mRootView.findViewById(R.id.session_list);
mLV.setAdapter(SessionManager.getInstance(getActivity().getApplicationContext()));
mLV.setDivider(new ColorDrawable(Color.RED));
mLV.setDividerHeight(20);
mLV.setBackground(new ColorDrawable(Color.YELLOW));
The ListView is a Fragment of a ViewPager and the only thing shown at screen ListView是ViewPager的片段,屏幕上唯一显示的内容
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/session_list"
style="@style/main.list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:smoothScrollbar="true">
</ListView>
The style for completion 完成风格
<style name="main">
</style>
<style name="main.list">
<item name="android:divider">#f00</item>
<item name="android:dividerHeight">4px</item>
</style>
<style name="main.list.item">
<item name="android:textColor">#f00</item>
<item name="android:textSize">32dp</item>
<item name="android:layout_height">48dp</item>
<item name="android:layout_width">match_parent</item>
<item name="android:background">#0ff</item>
</style>
The divider is not shonw. 分频器没有消失。 Instead the yellow background is visible.
而是可以看到黄色背景。 Any ideas?
有任何想法吗?
EDIT: if I pull up the listview fast enough the top is red. 编辑:如果我拉列表视图足够快的顶部是红色。 (The "overshoot" part of the scrolling)
(滚动的“过冲”部分)
If you are changing the colour/drawable, you have to set/reset the height of the divider too. 如果要更改颜色/可绘制对象,则还必须设置/重置分隔线的高度。 i have tried it out with
我已经尝试过了
<ListView
android:id="@+id/listViewInstituate"
android:layout_width="fill_parent"
android:layout_height="313dp"
android:choiceMode="singleChoice"
android:dividerHeight="1.9dp"
android:divider="@android:color/holo_red_light"
>
</ListView>
and it works fine. 而且效果很好。
but this needs api level 14, 但这需要api级别14,
android:divider="@android:color/holo_red_light"
so you can use 所以你可以使用
android:divider="#FFCC00"
i checked both. 我都检查了。 Thank you
谢谢
in your code mLV.setDivider(new ColorDrawable(Color.RED));
在您的代码
mLV.setDivider(new ColorDrawable(Color.RED));
and <item name="android:divider">#f00</item>
make me confused 和
<item name="android:divider">#f00</item>
让我感到困惑
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.