Addo Well-Known Member Licensed User Longtime User Oct 27, 2019 #1 can i set the customlistview background color to gradient colors at run time ? i cannot find any property to do that
can i set the customlistview background color to gradient colors at run time ? i cannot find any property to do that
Erel B4X founder Staff member Licensed User Longtime User Oct 27, 2019 #2 Are you asking about the full list background or the background of each item? Both can be changed at runtime. Code: Dim sv As ScrollView = CLV.sv 'create a GradientDrawable and set it to sv.Background Upvote 0
Are you asking about the full list background or the background of each item? Both can be changed at runtime. Code: Dim sv As ScrollView = CLV.sv 'create a GradientDrawable and set it to sv.Background
Addo Well-Known Member Licensed User Longtime User Oct 27, 2019 #4 i have did like following Code: Dim sv As ScrollView = clv.sv Dim gd(2) As Int gd(0) = Colors.RGB(0, 95, 170) gd(1) = Colors.RGB(0, 190, 255) Dim gdContent As GradientDrawable gdContent.Initialize("LEFT_RIGHT", gd) sv.Background = gdContent the clv background changed but the items inside the clv have a diffrent color any idea why ? Upvote 0
i have did like following Code: Dim sv As ScrollView = clv.sv Dim gd(2) As Int gd(0) = Colors.RGB(0, 95, 170) gd(1) = Colors.RGB(0, 190, 255) Dim gdContent As GradientDrawable gdContent.Initialize("LEFT_RIGHT", gd) sv.Background = gdContent the clv background changed but the items inside the clv have a diffrent color any idea why ?
Addo Well-Known Member Licensed User Longtime User Oct 27, 2019 #5 should i loop through clv items and set each item panel background as gradient as well or there is more simple way ? Upvote 0
should i loop through clv items and set each item panel background as gradient as well or there is more simple way ?
mangojack Expert Licensed User Longtime User Oct 27, 2019 #6 PassionDEV said: should i loop through clv items and set each item panel background as gradient as well or there is more simple way ? Click to expand... You could do that ... Or In your CLV Item layout place views on a Panel and set the background tp GradientDrawable ... Or Color the Item Panel when loading items to the CLV. Code: Sub CreateListItem(Text As String, Width As Int, Height As Int) As Panel Dim p As Panel p.Initialize("") 'set panel color gradient ... Not tested.! Upvote 0
PassionDEV said: should i loop through clv items and set each item panel background as gradient as well or there is more simple way ? Click to expand... You could do that ... Or In your CLV Item layout place views on a Panel and set the background tp GradientDrawable ... Or Color the Item Panel when loading items to the CLV. Code: Sub CreateListItem(Text As String, Width As Int, Height As Int) As Panel Dim p As Panel p.Initialize("") 'set panel color gradient ... Not tested.!
Addo Well-Known Member Licensed User Longtime User Oct 28, 2019 #7 I think its better to use a timer in my case sense I will change the clv colors each 1 minute. Also timer could be a good choice sense each time I put the application to background or open the keyboard the clv gradient background cleared and had to be re drawed. Upvote 0
I think its better to use a timer in my case sense I will change the clv colors each 1 minute. Also timer could be a good choice sense each time I put the application to background or open the keyboard the clv gradient background cleared and had to be re drawed.
Addo Well-Known Member Licensed User Longtime User Oct 28, 2019 #8 @mangojack i have also tried to do the same method you have posted like following Code: Sub CreateListItem(Text As String, Width As Int, Height As Int) As Panel Dim itempnl As Panel itempnl.Initialize("") itempnl.LoadLayout("itemlayout") Dim gd(2) As Int gd(0) = Colors.White gd(1) = Colors.Blue Dim gdContent As GradientDrawable gdContent.Initialize("LEFT_RIGHT", gd) itempnl.Background = gdContent Return itempnl End Sub i got this exception when ever i try to set background java.lang.NullPointerException: Attempt to invoke virtual method 'int android.content.res.ColorStateList.getDefaultColor()' on a null object reference Click to expand... what iam doing wrong ? Upvote 0
@mangojack i have also tried to do the same method you have posted like following Code: Sub CreateListItem(Text As String, Width As Int, Height As Int) As Panel Dim itempnl As Panel itempnl.Initialize("") itempnl.LoadLayout("itemlayout") Dim gd(2) As Int gd(0) = Colors.White gd(1) = Colors.Blue Dim gdContent As GradientDrawable gdContent.Initialize("LEFT_RIGHT", gd) itempnl.Background = gdContent Return itempnl End Sub i got this exception when ever i try to set background java.lang.NullPointerException: Attempt to invoke virtual method 'int android.content.res.ColorStateList.getDefaultColor()' on a null object reference Click to expand... what iam doing wrong ?
Erel B4X founder Staff member Licensed User Longtime User Oct 28, 2019 #9 1. Never call LoadLayout on a zero sized panel. Code: Dim itempnl As B4XView = XUI.CreatePanel("") itempnl.SetLayoutAnimated(0, 0, 0, Width, Height) 2. xCLV expects the root panel color to be a solid color. Add another panel in the layout that is anchored to BOTH sides and then change its background. Upvote 0
1. Never call LoadLayout on a zero sized panel. Code: Dim itempnl As B4XView = XUI.CreatePanel("") itempnl.SetLayoutAnimated(0, 0, 0, Width, Height) 2. xCLV expects the root panel color to be a solid color. Add another panel in the layout that is anchored to BOTH sides and then change its background.