该片段正在显示徽标和名称.
但是在RecyclerVIEw中,你几乎看不到玩家的名字,因为它太白了,其他3个小文字也难以阅读.
它看起来像文本改变它的颜色以适应一些黑色主题,而通过我的所有应用程序,它是默认的theme.AppCompat.light.DarkActionbar
编辑一切看起来很好:
并且一个视图持有者的代码看起来也很好:
<?xml version="1.0" enCoding="utf-8"?><relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:layout_wIDth="match_parent" androID:layout_height="match_parent"> <TextVIEw androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:textAppearance="?androID:attr/textAppearanceMedium" androID:textStyle="bold" androID:text="12: Tyler Blackett" androID:ID="@+ID/txt_players_name" androID:layout_marginleft="12dp" androID:layout_marginStart="12dp" androID:layout_margintop="8dp"/> <TextVIEw androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:textAppearance="?androID:attr/textAppearanceSmall" androID:text="Small Text" androID:ID="@+ID/txt_players_position" androID:layout_below="@+ID/txt_players_name" androID:layout_alignleft="@+ID/txt_players_name" androID:layout_alignStart="@+ID/txt_players_name" /> <TextVIEw androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:textAppearance="?androID:attr/textAppearanceSmall" androID:text="Small Text" androID:ID="@+ID/txt_players_nationality" androID:layout_below="@+ID/txt_players_position" androID:layout_alignleft="@+ID/txt_players_position" androID:layout_alignStart="@+ID/txt_players_position" /> <TextVIEw androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:textAppearance="?androID:attr/textAppearanceSmall" androID:text="Small Text" androID:ID="@+ID/txt_players_value" androID:layout_below="@+ID/txt_players_nationality" androID:layout_alignleft="@+ID/txt_players_nationality" androID:layout_alignStart="@+ID/txt_players_nationality" /></relativeLayout>
编辑:适配器的一些代码.我多次使用这个适配器(情况0,1,2),只有在这种情况下,它正在改变文本的颜色:
public RecyclerVIEw.VIEwHolder onCreateVIEwHolder(VIEwGroup parent,int vIEwType) { VIEw vIEw; RecyclerVIEw.VIEwHolder vIEwHolder = null; switch(vIEwType){ case 0: vIEw = inflater.inflate(R.layout.row_teams,parent,false); vIEwHolder = new VIEwHolder0(vIEw); break; //working fine case 1: {...} //working fine case 2: {...} //working fine case 3: vIEw = inflater.inflate(R.layout.row_players,false); vIEwHolder = new VIEwHolder3(vIEw); } return vIEwHolder; }
在onBind中,我只需将.setText调用到TextVIEw,没有什么不寻常的.
持有人类:
public class VIEwHolder3 extends RecyclerVIEw.VIEwHolder { TextVIEw mPlayername; TextVIEw mposition; TextVIEw mNationality; TextVIEw mValue; public VIEwHolder3(VIEw itemVIEw) { super(itemVIEw); mPlayername = (TextVIEw) itemVIEw.findVIEwByID(R.ID.txt_players_name); mposition = (TextVIEw) itemVIEw.findVIEwByID(R.ID.txt_players_position); mNationality = (TextVIEw) itemVIEw.findVIEwByID(R.ID.txt_players_nationality); mValue = (TextVIEw) itemVIEw.findVIEwByID(R.ID.txt_players_value); }解决方法 我只是遇到了同样的问题,这是因为我在RecyclerVIEw中使用了一个用应用程序的Context创建的LayoutInflater,而不是当前的Activity.
将其更改为从Activity创建后,RecyclerVIEw颜色变回黑色.
总结以上是内存溢出为你收集整理的android – RecyclerView TextView文本颜色改变了全部内容,希望文章能够帮你解决android – RecyclerView TextView文本颜色改变了所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)