Can Korkmaz
07/21/2022, 5:42 PMCannot create Typeface from ResourceFont(resId=2131296260, weight=FontWeight(weight=400), style=Normal)
Can Korkmaz
07/21/2022, 5:45 PM@RequiresApi(Build.VERSION_CODES.M)
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
hideAppBar()
/*_binding = FragmentLandingBinding.inflate(inflater, container, false)
//val view = binding.root
binding.composeViewLandingScreen.apply {
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnLifecycleDestroyed(viewLifecycleOwner))
setContent {
LandingScreen(landingViewModel)
}
}*/
return ComposeView(requireContext()).apply{
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnLifecycleDestroyed(viewLifecycleOwner))
setContent {
LandingScreenRadioGroup()
//LandingScreen(landingViewModel)
}
}
}
Composable:
@Composable
fun LandingScreenRadioGroup(
onRadioGroupCheckedChanged: (optionName: String) -> Unit = {},
) {
Row(
Modifier
.fillMaxWidth()
.wrapContentHeight()
.padding(top = 4.dp)
) {
val currentButton = remember { mutableStateOf(0) }
val radioGroupOptions = listOf("TRY", "TRYB", "USDT")
LaunchedEffect(key1 = currentButton.value) {
onRadioGroupCheckedChanged(radioGroupOptions[currentButton.value])
}
for (i in radioGroupOptions.indices) {
CustomButtonPrimary(
text = radioGroupOptions[i],
onClick = {
currentButton.value = i
},
height = 34,
width = 52,
padding = PaddingValues(end = 8.dp),/*
buttonColors = ButtonDefaults.buttonColors(
backgroundColor = if (currentButton.value == i) colorResource(id = R.color.quoteAssetSelected) else colorResource(
id = R.color.quoteAssetDeselected
)
),*/
contentPaddingValues = PaddingValues(),
/*
textStyle = CustomTextAppearances.Medium.Standard.copy(
color = if (currentButton.value == i) colorResource(id = R.color.colorAccent) else colorResource(
id = R.color.colorWhite
)
)*/
)
}
}
}
Can Korkmaz
07/21/2022, 5:49 PMval MazzardBoldFontFamily =FontFamily(listOf(Font(R.font.mazzardbold)))
val MazzardSemiBoldFontFamily =FontFamily(listOf(Font(R.font.mazzardsemibold)))
val CustomTextAppearance: TextStyle
@Composable
get() = TextStyle(
color = colorResource(R.color.colorBlack),
fontSize = CustomTextSizes.STANDARD.size,
fontStyle = FontStyle.Normal,
letterSpacing = 1.0.sp,
fontFamily = FontFamily.SansSerif,
)
val Standard: TextStyle
@Composable
get() = CustomTextAppearance.copy(
fontWeight = FontWeight(400),
fontFamily = MazzardLightFontFamily,
fontSize = CustomTextSizes.STANDARD.size,
)
This is the way I created custom TextStyles.
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="<http://schemas.android.com/apk/res-auto>">
<font app:fontStyle="normal" app:fontWeight="400" app:font="@font/mazzardboldfont"/>
</font-family>
Siyamed
07/21/2022, 6:14 PMSiyamed
07/21/2022, 6:15 PMCan Korkmaz
07/21/2022, 6:26 PMreturn ComposeView(requireContext()).apply{
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnLifecycleDestroyed(viewLifecycleOwner))
setContent {
Text("Compose text without font", style CustomTextAppearances.Medium.Standard)
//LandingScreenRadioGroup()
//LandingScreen(landingViewModel)
}
}
}
This crashed while it runs when I remove the style parameter.Can Korkmaz
07/21/2022, 6:27 PMSiyamed
07/21/2022, 6:29 PMCan Korkmaz
07/21/2022, 6:33 PMCan Korkmaz
07/21/2022, 6:34 PMSiyamed
07/21/2022, 6:35 PM