In my PreferenceCategory the textview does开发者_运维问答 not change its height when the text becomes too long. It just breaks the line and looks weird, as the size is not changed... I have also tried ellipsizing, but without success... is there a way to get a preferencecategory-view to change its size or if not to ellipsize its content?
I just found it out myself how to get this TextView to ellipsize its content. Here's my solution:
Create a Custom PreferenceCategory and override onBindView(View view), the view-objects holds your TextView that you can get to ellipsize then...
public class CustomPreferenceCategory extends PreferenceCategory {
public CustomPreferenceCategory(Context context, AttributeSet attrs) {
    super(context, attrs);
}
@Override
protected void onBindView(View view) {
    super.onBindView(view);
    if(view instanceof TextView){
        TextView tv = (TextView)view;
        tv.setEllipsize(TruncateAt.END);
        tv.setLines(1);
        tv.setSingleLine();
    }
}
}
and reference it in your xml-preference layout like that:
<com.package.name.CustomPreferenceCategory android:key="KEY_ABC" />
thats all :-)
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论