直播平台源代码,TextView文本折叠查看显示更多效果

发布时间 2023-06-29 14:33:24作者: 云豹科技-苏凌霄

直播平台源代码,TextView文本折叠查看显示更多效果

1.collapsible_textview.xml定义

 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <TextView
        android:id="@+id/desc_tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="4.0dip"
        android:gravity="center_vertical"
        android:textColor="#ff000000"
        android:textSize="14.0dip" />
    
<!--可以灵活的将收藏的按钮至右 至左 居中  -->
    <TextView
        android:id="@+id/desc_op_tv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="4.0dip"
        android:gravity="right"
        
        android:singleLine="true"
        android:textColor="#ff576b95"
        android:textSize="14.0dip"
        android:visibility="gone" />
</LinearLayout>
 

2.使用:

 


public class Main extends Activity {
    String s = "但发斯蒂芬的佛教啊哦啊二等奖发了恐惧似懂非懂,爱递交奇怪阿尔发票奥支付到上世纪的阿斯顿发送到撒旦法大的事发的爱的色放的阿斯顿发阿斯顿发阿萨德发的多发点";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        CollapsibleTextView tv = (CollapsibleTextView) findViewById(R.id.desc_collapse_tv);
        tv.setDesc(s, BufferType.NORMAL);
        
        
        
    }
}

 

 以上就是 直播平台源代码,TextView文本折叠查看显示更多效果,更多内容欢迎关注之后的文章