【发布时间】:2016-11-29 14:33:31
【问题描述】:
我正在尝试使用 Xamarin.Forms 构建一个带有绿色边框的圆形按钮,使用一种我在以前的项目中使用的方法,将 BorderRadius、BorderColour 等值添加到 Button 元素。
请考虑以下代码:
Button goButton = new Button
{
Text = "GO!",
TextColor = Color.White,
FontSize = 75,
HeightRequest = 200,
WidthRequest = 200,
BorderRadius = 100,
BorderWidth = 10,
BorderColor = Color.Green,
BackgroundColor = Color.Red
};
上面的代码给了我以下不想要的输出:
我尝试在 XAML 中重写并遇到同样的问题,我还检查了我的 Xamarin 版本(和 NuGet Xamarin.forms 包)是否是最新的。然而在 iOS 版本上,一切看起来都是正确的(我想的一切都是第一次!)
我们将不胜感激在发现问题和解决此问题方面的任何帮助。
建议修改:
请在下面找到我的styles.xml
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="MainTheme" parent="MainTheme.Base">
</style>
<!-- Base theme applied no matter what API -->
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
<item name="windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette -->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#2196F3</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#1976D2</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">#FF4081</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal. -->
<item name="windowActionModeOverlay">true</item>
<item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
</style>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#FF4081</item>
</style>
</resources>
【问题讨论】:
标签: android xamarin xamarin.android xamarin.forms