BorderColor not picking the linearGradient color on android
You should add style to the TouchableOpacity:
style={{
width: 100,
height: 100, backgroundColor: 'transparent', overflow: "hidden", borderRadius: 50, flex: 1}}
in addition change the style of profilePhotoContainer to:
profilePhotoContainer: {
zIndex: 5,
position: 'absolute',
top: Dimensions.get('window').height * .13,
left: Dimensions.get('window').width / 2 - Dimensions.get('window').width * .13,
elevation: 4,
borderRadius: 75,
padding: 5,
overflow: "hidden",
borderColor: 'transparent',
}
Flutter - Access color from LinearGradient()
To extract a color from a LinearGradient() just use its .colors[index] property
for example here :
LinearGradient(
colors: [
Color(0xFFAF0000),
Color(0xFF12F000),
Color(0xFFFFA000),
],
).colors[2],
.colors[2] will get you the 3rd Color from this random LinearGradient()
-
So in your case just write :
Container(
color: niceGradient.colors[0])
to get the 1st color from your custom niceGradient ! : )
Hope it helps ! : )
flutter linear gradient color issue
Add this line in your main()
to make it softer,
void main(){
Paint.enableDithering = true;
...
is an android shape with a gradient border and transparent middle possible?
you can achieve this using jetpack compose then you can use interoperability API
@Composable
fun SetRing() {
Box(
modifier = Modifier
.background(Color.Transparent)
.border(
2.dp,
Brush.linearGradient(
colors = listOf(
Color.Yellow,
Color.Blue
)
),
shape = RoundedCornerShape(5.dp)
)
.padding(6.dp)
) {
Text(text = "Hiphop")
}
}
interoperability API,
in XML file
<androidx.compose.ui.platform.ComposeView
android:id="@+id/compose_interest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
[output]
Xamarin Forms LinearGradientBrush of Frame not working when colors are set from Dynamic Style
The second sample - binding to a Xamarin.Forms.Color object does not work at all.
The second question is need to set Path to a sub-property to do the binding.
Set the Name of the page.
x:Name="root"
Style with binding:
<Style x:Key="wlHeaderGradient1" TargetType="Frame">
<Setter Property="BorderColor" Value="Purple" />
<Setter Property="HasShadow" Value="False" />
<Setter Property="CornerRadius" Value="0" />
<Setter Property="HeightRequest" Value="100" />
<Setter Property="WidthRequest" Value="100"/>
<Setter Property="HorizontalOptions" Value="Center" />
<Setter Property="VerticalOptions" Value="Center" />
<Setter Property="Background">
<LinearGradientBrush EndPoint="0,1">
<GradientStop Color="{Binding Path = BindingContext.CheckInHeaderBgColor1 ,Source={x:Reference root}}" Offset="0.0" />
<GradientStop Color="{Binding Path = BindingContext.CheckInHeaderBgColor2 ,Source={x:Reference root}}" Offset="0.5" />
<GradientStop Color="{Binding Path = BindingContext.CheckInHeaderBgColor1 ,Source={x:Reference root}}" Offset="1.0" />
</LinearGradientBrush>
</Setter>
</Style>
Xaml:
<StackLayout Orientation="Vertical" HorizontalOptions="Center" VerticalOptions="Start">
<StackLayout Orientation="Horizontal" HorizontalOptions="Center" VerticalOptions="Start">
<Frame Style="{StaticResource wlHeaderGradient1}" x:Name="frmTest1" >
</Frame>
</StackLayout>
</StackLayout>
Code behind:
public Page12()
{
InitializeComponent();
this.BindingContext = new HostPublicStyleInfo();
}
ViewModel:
public class HostPublicStyleInfo
{
public HostPublicStyleInfo()
{
CheckInHeaderBgColor1 = "#FF008080";
CheckInHeaderBgColor2 = "#FFFF6347";
frmTest2Style = "frmTest2GradientStyle";
}
public string frmTest2Style { get; set; }
public string CheckInHeaderBgColor1 { get; set; }
public string CheckInHeaderBgColor2 { get; set; }
}
The third example, attempting to use the dynamic resources never updates to the new colors (they stay the static black and white values) even though I have ensured the values are being changed when the custom color objects are being loaded.
Set the White-Black-White in Style instead of in Frame.
<Style x:Key="wlHeaderGradient2" TargetType="Frame">
<Setter Property="BorderColor" Value="Purple" />
<Setter Property="HasShadow" Value="False" />
<Setter Property="CornerRadius" Value="0" />
<Setter Property="HeightRequest" Value="100" />
<Setter Property="WidthRequest" Value="100"/>
<Setter Property="HorizontalOptions" Value="Center" />
<Setter Property="VerticalOptions" Value="Center" />
<Setter Property="Background">
<LinearGradientBrush EndPoint="0,1">
<GradientStop Color="{DynamicResource grdHeaderBGColor1}" Offset="0.0" />
<GradientStop Color="{DynamicResource grdHeaderBGColor2}" Offset="0.5" />
<GradientStop Color="{DynamicResource grdHeaderBGColor1}" Offset="1.0" />
</LinearGradientBrush>
</Setter>
</Style>And then you could cover it with the new style. frmTest2GradientStyle is the style which i set in Application.Resources.
frmTest2.Style = (Style)Application.Current.Resources["frmTest2GradientStyle"];
If you set the background in Frame like below, you could change the background instead of Background.
<Frame x:Name="frmTest3" Style="{StaticResource wlHeaderGradient2}">
<Frame.Background>
<LinearGradientBrush EndPoint="0,1">
<GradientStop Color="{DynamicResource grdHeaderBGColor1}" Offset="0.0" />
<GradientStop Color="{DynamicResource grdHeaderBGColor2}" Offset="0.5" />
<GradientStop Color="{DynamicResource grdHeaderBGColor1}" Offset="1.0" />
</LinearGradientBrush>
</Frame.Background>
</Frame>Change the background in code:
GradientStopCollection gradientStops = new GradientStopCollection();
gradientStops.Add(new GradientStop() { Color = Color.Green, Offset = (float)0.0 });
gradientStops.Add(new GradientStop() { Color = Color.Red, Offset = (float)0.5 });
gradientStops.Add(new GradientStop() { Color = Color.Green, Offset = (float)1.0 });
LinearGradientBrush linearGradientBrush = new LinearGradientBrush()
{
EndPoint = new Point(0, 1),
GradientStops = gradientStops
};
frmTest3.Background = linearGradientBrush;
Transparent text cut out of background
It's possible with css3 but it's not supported in all browsers
With background-clip: text; you can use a background for the text, but you will have to align it with the background of the page
body {
background: url(http://www.color-hex.com/palettes/26323.png) repeat;
margin:10px;
}
h1 {
background-color:#fff;
overflow:hidden;
display:inline-block;
padding:10px;
font-weight:bold;
font-family:arial;
color:transparent;
font-size:200px;
}
span {
background: url(http://www.color-hex.com/palettes/26323.png) -20px -20px repeat;
-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
display:block;
}
<h1><span>ABCDEFGHIKJ</span></h1>
Related Topics
How to Create an Android Activity and Service That Use Separate Processes
How to Scroll Recyclerview Programmatically
Android: Using HTML5 to Determine Geolocation in Webview with JavaScript API
Mysterious Stacktrace in Android Developer Console (Bitmap Size Exceeds 32Bits)
Android Ndk Std::To_String Support
Parsing Date/Time to Localtimezone
Firebase Servervalue.Timestamp in Java Data Models Objects
How to Have a Masked Numeric Input Field
A Correct Way to Convert Byte[] in Java to Unsigned Char* in C++, and Vice Versa
How to Add Network_Security_Config.Xml to Manifest in Expo App Without Ejecting
Call Recorder Not Working in Android 10 (Q)
Android Listview Child View Setenabled() and Setclickable() Do Nothing
Eclipse Indexer Errors When Using Stl with Android Ndk
Fragment's Onsaveinstancestate() Is Never Called