【发布时间】:2018-12-22 08:58:37
【问题描述】:
我想有一个非常简单的问题......
我有一个 textview,我希望 TextView 有一个边框,所以我这样做了:
<TextView
android:text="Status"
android:layout_width="wrap_content"
android:layout_weight="16"
android:layout_height="150px"
android:id="@+id/txtStatus"
android:textColor="#000000"
android:textSize="50px"
android:paddingTop="20px"
android:paddingLeft="3dip"
android:background="@drawable/list_divider"/>
list_divider.xml 包含以下内容:
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<stroke
android:width="1dp"
android:color="#FF000000" />
</shape>
此代码有效,但在 c# 类中,我使用以下命令设置背景颜色:
txtStatus.SetBackgroundColor(Color.ParseColor("#FF746B"));
但是当我使用该命令时,它会覆盖边框。我怎样才能同时拥有边框和背景颜色。我无法在 list_divider.xml 中分配它们,因为颜色取决于 TextView 的值。
所以要明确一点,我怎样才能在 textview 上同时拥有边框和背景颜色?
【问题讨论】:
标签: c# android xamarin xamarin.forms