android中怎么在文字两边划线
在 Android 开发中如何实现在文字两边划线?
一个简单的思路就是在 TextView 两边加上 View。并控制 View 的显示方式。效果如下:
具体代码如下:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/rl"
android:orientation="horizontal"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="1dp"
android:gravity="center">
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_weight="1"
android:background="@color/white"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:text="第三方登录"
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="18sp" />
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_weight="1"
android:background="@color/white"
/>
</LinearLayout>