Issue
I'm trying to create a widget for Android in my Xamarin.Forms app. The example I'm trying to practice at is here: AppWidgetListView. The trouble is, that I can't find a way to change the color of TextBox background. The remoteView.setInt(R.id.container, "SetBackgroundColor", backgroundColor);
which is appropriate for Java doesn't work in Xamarin. Moreover, it doesn't even changes the drawable picture.
Please, could you help me?
Solution
You can do it directly in layout list_row.xml
, just set the background on the root layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:background="@android:color/holo_green_dark" > //this line
If you want to change it in code
//ListProvider.cs
public RemoteViews GetViewAt(int position)
{
RemoteViews remoteView = new RemoteViews( context.PackageName, Resource.Layout.list_row);
//add this line
remoteView.SetInt(Resource.Id.container, "setBackgroundColor", Android.Graphics.Color.Red);
...
}
Answered By - ColeX - MSFT
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.