最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android實現(xiàn)文字下方加橫線

 更新時間:2020年07月24日 08:37:02   作者:青城學(xué)者  
這篇文章主要為大家詳細(xì)介紹了Android實現(xiàn)文字下方加橫線,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了Android實現(xiàn)文字下方加橫線的具體代碼,供大家參考,具體內(nèi)容如下

public class WhiteTextviewWithWhiteBottomLine extends LinearLayout {
 
 private Context mContext;
 
 public WhiteTextviewWithWhiteBottomLine(Context context) {
  this(context, null);
 }
 
 public WhiteTextviewWithWhiteBottomLine(Context context, @Nullable AttributeSet attrs) {
  this(context, attrs, 0);
 }
 
 public WhiteTextviewWithWhiteBottomLine(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
  super(context, attrs, defStyleAttr);
  mContext = context;
  initViews();
 }
 
 private TextView textView;
 private View viewLine;
 
 private void initViews() {
  View view = View.inflate(mContext, R.layout.view_textview_with_bottom_line, null);
 
  textView = view.findViewById(R.id.tv_view_textview_with_line);
  viewLine = view.findViewById(R.id.view_view_textview_with_line);
 
  this.addView(view);
 
  setSelected(false);
 }
 
 public void setTextViewText(String s) {
  textView.setText(s);
 }
 
 public void setLineColor(@ColorInt int color) {
  viewLine.setBackgroundColor(color);
 }
 
 public void setSelected(boolean isSelected) {
 
  if (isSelected) {
   viewLine.setVisibility(VISIBLE);
  } else {
   viewLine.setVisibility(GONE);
  }
 }
 
 public boolean isSelected() {
  if (viewLine.getVisibility() == View.VISIBLE) {
   return true;
  }else {
   return false;
  }
 }
}

布局文件:

<?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">
 
 <LinearLayout
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:gravity="center"
  android:orientation="vertical">
 
  <TextView
   android:id="@+id/tv_view_textview_with_line"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:gravity="center"
   android:padding="10dp"
   android:text="測試"
   android:textColor="@color/white"
   android:textSize="12sp" />
 
  <View
   android:id="@+id/view_view_textview_with_line"
   android:layout_width="30dp"
   android:layout_height="1dp"
   android:layout_gravity="center_horizontal"
   android:background="@color/white" />
 
 </LinearLayout>
 
</LinearLayout>

如果想改變文字、線的顏色這些,直接修改布局文件中的內(nèi)容。

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

拉孜县| 鹤峰县| 天镇县| 星子县| 岱山县| 梧州市| 刚察县| 浦北县| 普兰县| 建阳市| 长白| 洛扎县| 汝城县| 昌黎县| 榆林市| 铜川市| 绥阳县| 峨边| 尖扎县| 洛浦县| 凤阳县| 阿巴嘎旗| 上虞市| 东乌| 天门市| 太和县| 乌拉特前旗| 南乐县| 腾冲县| 和硕县| 外汇| 五华县| 永修县| 扶沟县| 天台县| 祁东县| 武山县| 公主岭市| 郧西县| 湟中县| 台山市|