This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun SpringRelease() { | |
val offsetY = remember { Animatable(0f) } | |
val scope = rememberCoroutineScope() | |
Box( | |
modifier = Modifier | |
.fillMaxSize() | |
.padding(20.dp), | |
contentAlignment = Alignment.TopCenter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends AppCompatActivity implements WifiChangeBroadcastReceiver.WifiChangeBroadcastListener { | |
private WifiManager wifiManager; | |
private ConnectivityManager connectivityManager; | |
private WifiChangeBroadcastReceiver wifiStateChangeReceiver; | |
@Override | |
protected void onCreate(@Nullable Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun SpringAnimation() { | |
val scope = rememberCoroutineScope() | |
val offset = remember { Animatable(Offset(0f, 0f), Offset.VectorConverter) } | |
val offset2 = remember { Animatable(Offset(0f, 0f), Offset.VectorConverter) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@OptIn(ExperimentalTextApi::class) | |
@Composable | |
fun ExampleTextOverFlow() { | |
val textMeasure = rememberTextMeasurer() | |
Canvas( | |
onDraw = { | |
drawRect(color = Color.Black) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@OptIn(ExperimentalTextApi::class) | |
@Composable | |
fun ExampleTextLayoutResult() { | |
val textMeasure = rememberTextMeasurer() | |
var textLayoutResult by remember { mutableStateOf<TextLayoutResult?>(null) } | |
Canvas( | |
modifier = Modifier | |
.fillMaxWidth() | |
.height(100.dp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val textMeasure = rememberTextMeasurer() | |
var textLayoutResult by remember { mutableStateOf<TextLayoutResult?>(null) } | |
Canvas( | |
modifier = Modifier | |
.layout { measurable, constraints -> | |
val placeable = measurable.measure(constraints) | |
textLayoutResult = textMeasure.measure( | |
AnnotatedString("Text on Canvas!"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ExperimentalTextApi | |
fun DrawScope.drawText( | |
textLayoutResult: TextLayoutResult, | |
color: Color = Color.Unspecified, | |
topLeft: Offset = Offset.Zero, | |
alpha: Float = Float.NaN, | |
shadow: Shadow? = null, | |
textDecoration: TextDecoration? = null | |
){} | |
@ExperimentalTextApi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun ExampleTextString() { | |
val textMeasure = rememberTextMeasurer() | |
Canvas(modifier = Modifier | |
.fillMaxWidth() | |
.height(100.dp), onDraw = { | |
drawRect(color = Color.Black) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ExperimentalTextApi | |
fun DrawScope.drawText( | |
textMeasurer: TextMeasurer, | |
text: String, | |
// Other configuration | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@OptIn(ExperimentalTextApi::class) | |
@Composable | |
fun ExampleTextAnnotatedString() { | |
val textMeasure = rememberTextMeasurer() | |
val text = buildAnnotatedString { | |
withStyle( | |
style = SpanStyle( | |
color = Color.White, |
NewerOlder