Commit 3d2a4c34 authored by jiangyh's avatar jiangyh

android页面

parent ebf023b5
package com.example.testdemo package com.example.testdemo
import android.app.Activity
import android.os.Bundle import android.os.Bundle
import android.view.Gravity
import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import androidx.activity.ComponentActivity import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent import androidx.activity.compose.setContent
...@@ -13,10 +16,19 @@ class MainActivity : ComponentActivity() { ...@@ -13,10 +16,19 @@ class MainActivity : ComponentActivity() {
val message = com.example.testdemo.appInfo() val message = com.example.testdemo.appInfo()
// 如果你用原生 View val root = LinearLayout(this).apply {
setContentView(TextView(this).apply { orientation = LinearLayout.VERTICAL
gravity = Gravity.CENTER
setPadding(24, 24, 24, 24)
}
val msgView = TextView(this).apply {
text = message text = message
textSize = 24f textSize = 24f
}) }
root.addView(msgView)
setContentView(root)
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment