本文整理汇总了C#中Android.Widget.TextView.SetBackgroundColor方法的典型用法代码示例。如果您正苦于以下问题:C# TextView.SetBackgroundColor方法的具体用法?C# TextView.SetBackgroundColor怎么用?C# TextView.SetBackgroundColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Widget.TextView
的用法示例。
在下文中一共展示了TextView.SetBackgroundColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
var display = WindowManager.DefaultDisplay;
var horiPager = new HorizontalPager(this.ApplicationContext, display);
horiPager.ScreenChanged += new ScreenChangedEventHandler(horiPager_ScreenChanged);
//You can also use:
/*horiPager.ScreenChanged += (sender, e) =>
{
System.Diagnostics.Debug.WriteLine("Switched to screen: " + ((HorizontalPager)sender).CurrentScreen);
};*/
var backgroundColors = new Color[] { Color.Red, Color.Blue, Color.Cyan, Color.Green, Color.Yellow };
for (int i = 0; i < 5; i++)
{
var textView = new TextView(this.ApplicationContext);
textView.Text = (i + 1).ToString();
textView.TextSize = 100;
textView.SetTextColor(Color.Black);
textView.Gravity = GravityFlags.Center;
textView.SetBackgroundColor(backgroundColors[i]);
horiPager.AddView(textView);
}
SetContentView(horiPager);
}
示例2: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
var mLayout = new FrameLayout(this);
surface = UrhoSurface.CreateSurface(this, typeof(MySample));
//surface.Background.SetAlpha(10);
TextView txtView = new TextView(this);
txtView.SetBackgroundColor(Color.Violet);
txtView.SetWidth(10);
txtView.SetHeight(10);
txtView.Text = "HAHAH";
//txtView.Text = surface.Background.ToString();
Button btn = new Button(this);
btn.SetBackgroundColor(Color.Transparent);
btn.Text = "Button";
btn.SetHeight(100);
btn.SetWidth(100);
btn.SetX(30);
btn.SetY(30);
btn.TextAlignment = TextAlignment.Center;
mLayout.AddView(txtView);
mLayout.AddView(btn);
mLayout.AddView(surface);
SetContentView(mLayout);
}
示例3: StyleUILabel
public static void StyleUILabel( TextView label, string font, uint size )
{
label.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Label_TextColor ) );
label.SetBackgroundColor( Android.Graphics.Color.Transparent );
label.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( font ), TypefaceStyle.Normal );
label.SetTextSize( Android.Util.ComplexUnitType.Dip, size );
}
示例4: createColumn
private View createColumn(Context context, string ev)
{
TextView view = new TextView(context);
view.SetPadding(20, 0, 0, 0);
view.SetBackgroundColor(Android.Graphics.Color.White);
view.Text = ev;
view.SetTextColor(Android.Graphics.Color.ParseColor("#3B3477"));
return view;
}
示例5: OnElementChanged
protected override void OnElementChanged (ElementChangedEventArgs<Page> e)
{
base.OnElementChanged (e);
MessagingCenter.Subscribe<RootPage, AlertArguments> (this, "DisplayAlert", (sender, arguments) => {
//If you would like to use style attributes, you can pass this into the builder
// ContextThemeWrapper customDialog = new ContextThemeWrapper(Context, Resource.Style.AlertDialogCustom);
// AlertDialog.Builder builder = new AlertDialog.Builder(customDialog);
//Create instance of AlertDialog.Builder and create the alert
AlertDialog.Builder builder = new AlertDialog.Builder(Context);
var alert = builder.Create();
//Utilize context to get LayoutInflator to set the view used for the dialog
var layoutInflater = (LayoutInflater) Context.GetSystemService(Context.LayoutInflaterService);
alert.SetView(layoutInflater.Inflate(Resource.Layout.CustomDialog,null));
//Create a custom title element
TextView title = new TextView (Context) {
Text = arguments.Title,
};
title.SetTextColor(Android.Graphics.Color.DodgerBlue);
title.SetBackgroundColor(Android.Graphics.Color.White);
//Add the custom title to the AlertDialog
alert.SetCustomTitle(title);
//Set the buttons text and click handler events
if (arguments.Accept != null)
alert.SetButton ((int)DialogButtonType.Positive, arguments.Accept, (o, args) => arguments.SetResult (true));
alert.SetButton ((int)DialogButtonType.Negative, arguments.Cancel, (o, args) => arguments.SetResult (false));
alert.CancelEvent += (o, args) => { arguments.SetResult (false); };
alert.Show ();
//This code grabs the line that separates the title and dialog.
int titleDividerId = Resources.GetIdentifier("titleDivider", "id", "android");
Android.Views.View titleDivider = alert.FindViewById(titleDividerId);
if (titleDivider != null)
titleDivider.SetBackgroundColor(Android.Graphics.Color.DarkRed);
//Set properties of the buttons
Android.Widget.Button positiveButton = alert.GetButton((int)DialogButtonType.Positive);
positiveButton.SetTextColor(Android.Graphics.Color.Green);
positiveButton.SetBackgroundColor(Android.Graphics.Color.White);
Android.Widget.Button negativeButton = alert.GetButton((int)DialogButtonType.Negative);
negativeButton.SetTextColor(Android.Graphics.Color.Red);
negativeButton.SetBackgroundColor(Android.Graphics.Color.White);
//Set the text of the TextView in the dialog
var textView = alert.FindViewById<TextView>(Resource.Id.textview);
textView.SetText(arguments.Message,null);
});
}
示例6: CreateView
private View CreateView(TestRunInfo testRunDetails)
{
LinearLayout layout = new LinearLayout(this);
layout.Orientation = Orientation.Vertical;
TextView titleTextView = new TextView(this);
titleTextView.LayoutParameters = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FillParent, 48);
titleTextView.SetBackgroundColor(Color.Argb(255,50,50,50));
titleTextView.SetPadding(20,0,20,0);
titleTextView.Gravity = GravityFlags.CenterVertical;
titleTextView.Text = testRunDetails.Description;
titleTextView.Ellipsize = TextUtils.TruncateAt.Start;
TextView descriptionTextView = new TextView(this);
descriptionTextView.LayoutParameters = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent)
{
LeftMargin = 40,
RightMargin = 40
};
if (testRunDetails.Running)
{
descriptionTextView.Text = "Test is currently running.";
}
else if (testRunDetails.Passed)
{
descriptionTextView.Text = "wohhoo, Test has passed.";
}
else if (testRunDetails.TestResult != null)
{
descriptionTextView.Text = testRunDetails.TestResult.Message + "\r\n\r\n" + testRunDetails.TestResult.StackTrace;
}
ScrollView scrollView = new ScrollView(this);
scrollView.LayoutParameters = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.FillParent);
scrollView.AddView(descriptionTextView);
layout.AddView(titleTextView);
layout.AddView(scrollView);
return layout;
}
示例7: OnCreate
// [END mListener_variable_reference]
// [START auth_oncreate_setup_beginning]
protected override void OnCreate (Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
// Put application specific code here.
// [END auth_oncreate_setup_beginning]
SetContentView (Resource.Layout.activity_main);
logView = FindViewById<TextView> (Resource.Id.sample_logview);
logView.SetTextAppearance (this, Resource.Style.Log);
logView.SetBackgroundColor (Android.Graphics.Color.White);
logView.Append ("\r\n");
// [START auth_oncreate_setup_ending]
if (savedInstanceState != null)
authInProgress = savedInstanceState.GetBoolean (AUTH_PENDING);
buildFitnessClient();
}
示例8: UpdateMemoryTableUI
private void UpdateMemoryTableUI()
{
tlData.RemoveAllViews();
foreach (var memoryItem in store.Items)
{
TableRow tr = new TableRow(this);
var rowColor = Color.White;
tr.SetBackgroundColor(rowColor);
var cellColor = Color.Black;
var txtVal1 = new TextView(this) {Text = memoryItem.Values[0]};
txtVal1.SetPadding(1, 1, 1, 1);
tr.AddView(txtVal1);
txtVal1.SetBackgroundColor(cellColor);
var txtVal2 = new TextView(this) {Text = memoryItem.Values[1]};
txtVal2.SetPadding(1, 1, 1, 1);
txtVal2.SetBackgroundColor(cellColor);
tr.AddView(txtVal2);
tlData.AddView(tr);
}
}
示例9: OnElementChanged
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
nativeTextView = Control;
if (nativeTextView == null)
{
return;
}
if (this.Element != null)
formsEntry = this.Element as CustomEntry;
if (formsEntry != null && !string.IsNullOrEmpty (formsEntry.BackGroundImageName)) {
Android.Graphics.Drawables.Drawable drawable = Resources.GetDrawable (Resource.Drawable.comnt_box);
nativeTextView.Background = drawable;
}
else
{
nativeTextView.SetBackgroundColor(Android.Graphics.Color.White);
nativeTextView.SetHintTextColor(Android.Graphics.Color.Gray);
}
nativeTextView.SetTextColor(Android.Graphics.Color.Gray);
if (nativeTextView != null)
{
if (nativeTextView.Text != null)
{
// nativeTextView.SetTextColor(Android.Graphics.Color.Black);
}
}
if (App.screenDensity > 1.5)
{
nativeTextView.SetTextSize(Android.Util.ComplexUnitType.Pt, 8);
}
else
{
nativeTextView.SetTextSize(Android.Util.ComplexUnitType.Pt, 9);
}
}
示例10: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
abs = new AbsoluteLayout(this);
sensorText = new TextView(this);
sensorText.SetBackgroundColor(new Color(192, 192, 192));
sensorText.Gravity = GravityFlags.Center;
SetContentView(abs);
sensorManager = (SensorManager)GetSystemService(SensorService);
//Point prealsize = new Point();
//WindowManager.DefaultDisplay.GetRealSize(prealsize); // ディスプレイサイズ取得(4.2以降)
//Log.Debug("Info", string.Format("Width(GetRealSize): {0}, Height(GetRealSize): {1}", prealsize.X ,prealsize.Y);
//Point psize = new Point();
//WindowManager.DefaultDisplay.GetSize(psize); // ナビゲーションバー以外のサイズ
//Log.Debug("Info", string.Format("Width(GetSize): {0}, Height(GetSize): {1}", psize.X, psize.Y);
}
示例11: OnCreate
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
//先初始化BMapManager
DemoApplication app = (DemoApplication)this.Application;
if (app.mBMapManager == null)
{
app.mBMapManager = new BMapManager(this);
app.mBMapManager.Init(
new DemoApplication.MyGeneralListener());
}
SetContentView(Resource.Layout.activity_panorama_main);
mPanoramaView = FindViewById<PanoramaView>(Resource.Id.panorama);
//UI初始化
mBtn = FindViewById<Button>(Resource.Id.button);
mBtn.Visibility = ViewStates.Invisible;
//道路名
mRoadName = FindViewById<TextView>(Resource.Id.road);
mRoadName.Visibility = ViewStates.Visible;
mRoadName.Text = "百度全景";
mRoadName.SetBackgroundColor(Color.Argb(200, 5, 5, 5)); //背景透明度
mRoadName.SetTextColor(Color.Argb(255, 250, 250, 250)); //文字透明度
mRoadName.TextSize = 22;
//跳转进度条
pd = new ProgressDialog(this);
pd.SetMessage("跳转中……");
pd.SetCancelable(true);//设置进度条是否可以按退回键取消
//初始化Searvice
mService = PanoramaService.GetInstance(ApplicationContext);
mCallback = new IPanoramaServiceCallbackImpl(this);
//设置全景图监听
mPanoramaView.SetPanoramaViewListener(this);
//解析输入
ParseInput();
}
示例12: TestRunDetailsView
public TestRunDetailsView(Context context, TestRunInfo testRunDetails) : base(context)
{
Orientation = Orientation.Vertical;
var titleTextView = new TextView(context)
{
LayoutParameters = new LayoutParams(ViewGroup.LayoutParams.FillParent, 48)
};
titleTextView.SetBackgroundColor(Color.Argb(255,50,50,50));
titleTextView.SetPadding(20,0,20,0);
titleTextView.Gravity = GravityFlags.CenterVertical;
titleTextView.Text = testRunDetails.Description;
titleTextView.Ellipsize = TextUtils.TruncateAt.Start;
_descriptionTextView = new TextView(context)
{
LayoutParameters = new LayoutParams(
ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent)
{
LeftMargin = 40,
RightMargin = 40
}
};
var scrollView = new ScrollView(context)
{
LayoutParameters = new LayoutParams(
ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent)
};
scrollView.AddView(_descriptionTextView);
AddView(titleTextView);
AddView(scrollView);
}
示例13: createDoubleHour
private View createDoubleHour(Context context, string ev)
{
TextView view = new TextView(context);
view.SetPadding(0, 0, 20, 0);
view.SetBackgroundColor(Android.Graphics.Color.White);
string[] spl = ev.Split('a');
view.Text = spl[0].TrimEnd(' ')+"\na"+spl[1];
view.SetTextColor(Android.Graphics.Color.ParseColor("#3B3477"));
view.Gravity = GravityFlags.Right;
return view;
}
示例14: OnCreate
/// <summary>
/// Raises the create event.
/// </summary>
/// <param name="bundle">Bundle.</param>
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// hide title bar.
this.RequestWindowFeature(global::Android.Views.WindowFeatures.NoTitle);
// initialize map.
var map = new Map();
map.AddLayer(new LayerMBTile(OsmSharp.Android.UI.Data.SQLite.SQLiteConnection.CreateFrom(
Assembly.GetExecutingAssembly().GetManifestResourceStream(@"OsmSharp.Android.UI.Sample.kempen.mbtiles"), "map")));
// add a tile layer.
//var layer = new LayerTile(@"http://a.tiles.mapbox.com/v3/osmsharp.i8ckml0l/{0}/{1}/{2}.png");
//map.AddLayer(layer);
//layer.IsVisible = false;
//map.AddLayer(new LayerTile(@"http://a.tiles.mapbox.com/v3/osmsharp.i8ckml0l/{0}/{1}/{2}.png"));
//map.AddLayerGpx(Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.regression1.gpx"));
//
// add an on-line osm-data->mapCSS translation layer.
//map.AddLayer(new OsmLayer(dataSource, mapCSSInterpreter));
// add a preprocessed vector data file.
//var sceneStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"OsmSharp.Android.UI.Sample.default.map");
//map.AddLayer(new LayerScene(Scene2D.Deserialize(sceneStream, true)));
//// define dummy from and to points.
//var from = new GeoCoordinate(51.261203, 4.780760);
//var to = new GeoCoordinate(51.267797, 4.801362);
//// deserialize the preprocessed graph.
//var routingSerializer = new CHEdgeDataDataSourceSerializer();
//var graphStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.kempen-big.osm.pbf.routing");
//var graphDeserialized = routingSerializer.Deserialize(graphStream, true);
//// initialize router.
//_router = Router.CreateCHFrom(graphDeserialized, new CHRouter(), new OsmRoutingInterpreter());
//// resolve points.
//var routerPoint1 = _router.Resolve(Vehicle.Car, from);
//var routerPoint2 = _router.Resolve(Vehicle.Car, to);
//// calculate route.
//var route = _router.Calculate(Vehicle.Car, routerPoint1, routerPoint2);
//// add a router layer.
//_routeLayer = new LayerRoute(map.Projection);
//_routeLayer.AddRoute(route, SimpleColor.FromKnownColor(KnownColor.Blue, 125).Value, 12);
//map.AddLayer(_routeLayer);
// define the mapview.
_mapView = new MapView(this, new MapViewSurface(this));
//_mapView = new MapView(this, new MapViewGLSurface(this));
//_mapView.MapTapEvent += new MapViewEvents.MapTapEventDelegate(_mapView_MapTapEvent);
_mapView.MapTapEvent += _mapView_MapTapEvent;
_mapView.Map = map;
//_mapView.MapMaxZoomLevel = 20;
//_mapView.MapMinZoomLevel = 10;
_mapView.MapTilt = 0;
_mapView.MapCenter = new GeoCoordinate(51.261203, 4.780760);
_mapView.MapZoom = 16;
_mapView.MapAllowTilt = false;
_mapView.MapTouchedUp += _mapView_MapTouchedUp;
_mapView.MapTouched += _mapView_MapTouched;
_mapView.MapTouchedDown += _mapView_MapTouchedDown;
// AddMarkers();
// AddControls();
// initialize a text view to display routing instructions.
_textView = new TextView(this);
_textView.SetBackgroundColor(global::Android.Graphics.Color.White);
_textView.SetTextColor(global::Android.Graphics.Color.Black);
// add the mapview to the linear layout.
var layout = new RelativeLayout(this);
//layout.Orientation = Orientation.Vertical;
//layout.AddView(_textView);
layout.AddView(_mapView);
// create the route tracker animator.
//_routeTrackerAnimator = new RouteTrackerAnimator(_mapView, routeTracker, 5, 17);
// simulate a mapzoom change every 5 seconds.
//Timer timer = new Timer(5000);
//timer.Elapsed += new ElapsedEventHandler(TimerHandler);
//timer.Start();
_centerMarker = _mapView.AddMarker(_mapView.MapCenter);
_mapView.MapInitialized += _mapView_MapInitialized;
SetContentView(layout);
}
示例15: DoubleNewsListItem
public DoubleNewsListItem( Context context ) : base( context )
{
Orientation = Orientation.Horizontal;
SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BackgroundColor ) );
LeftLayout = new RelativeLayout( Rock.Mobile.PlatformSpecific.Android.Core.Context );
LeftLayout.LayoutParameters = new LinearLayout.LayoutParams( NavbarFragment.GetCurrentContainerDisplayWidth( ) / 2, LayoutParams.WrapContent );
AddView( LeftLayout );
LeftImage = new Rock.Mobile.PlatformSpecific.Android.Graphics.AspectScaledImageView( Rock.Mobile.PlatformSpecific.Android.Core.Context );
LeftImage.LayoutParameters = new LinearLayout.LayoutParams( NavbarFragment.GetCurrentContainerDisplayWidth( ) / 2, LayoutParams.WrapContent );
( (LinearLayout.LayoutParams)LeftImage.LayoutParameters ).Gravity = GravityFlags.CenterVertical;
LeftImage.SetScaleType( ImageView.ScaleType.CenterCrop );
LeftLayout.AddView( LeftImage );
LeftButton = new Button( Rock.Mobile.PlatformSpecific.Android.Core.Context );
LeftButton.LayoutParameters = LeftImage.LayoutParameters;
LeftButton.Background = null;
LeftButton.Click += (object sender, EventArgs e ) =>
{
// notify our parent that the image index was clicked
ParentAdapter.RowItemClicked( LeftImageIndex );
};
LeftLayout.AddView( LeftButton );
LeftPrivateOverlay = new TextView( context );
LeftPrivateOverlay.LayoutParameters = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent );
LeftPrivateOverlay.SetBackgroundColor( Android.Graphics.Color.Red );
LeftPrivateOverlay.Alpha = .60f;
LeftPrivateOverlay.Text = "Private";
LeftPrivateOverlay.Gravity = GravityFlags.Center;
LeftLayout.AddView( LeftPrivateOverlay );
RightLayout = new RelativeLayout( Rock.Mobile.PlatformSpecific.Android.Core.Context );
RightLayout.LayoutParameters = new LinearLayout.LayoutParams( NavbarFragment.GetCurrentContainerDisplayWidth( ) / 2, LayoutParams.WrapContent );
AddView( RightLayout );
RightImage = new Rock.Mobile.PlatformSpecific.Android.Graphics.AspectScaledImageView( Rock.Mobile.PlatformSpecific.Android.Core.Context );
RightImage.LayoutParameters = new LinearLayout.LayoutParams( NavbarFragment.GetCurrentContainerDisplayWidth( ) / 2, LayoutParams.WrapContent );
( (LinearLayout.LayoutParams)RightImage.LayoutParameters ).Gravity = GravityFlags.CenterVertical;
RightImage.SetScaleType( ImageView.ScaleType.CenterCrop );
RightLayout.AddView( RightImage );
RightButton = new Button( Rock.Mobile.PlatformSpecific.Android.Core.Context );
RightButton.LayoutParameters = RightImage.LayoutParameters;
RightButton.Background = null;
RightButton.Click += (object sender, EventArgs e ) =>
{
// notify our parent that the image index was clicked
ParentAdapter.RowItemClicked( LeftImageIndex + 1 );
};
RightLayout.AddView( RightButton );
RightPrivateOverlay = new TextView( context );
RightPrivateOverlay.LayoutParameters = new RelativeLayout.LayoutParams( NavbarFragment.GetCurrentContainerDisplayWidth( ) / 2, ViewGroup.LayoutParams.WrapContent );
RightPrivateOverlay.SetBackgroundColor( Android.Graphics.Color.Red );
RightPrivateOverlay.Alpha = .60f;
RightPrivateOverlay.Text = "Private";
RightPrivateOverlay.Gravity = GravityFlags.Center;
RightLayout.AddView( RightPrivateOverlay );
}