I have button when click I want to show (View) and inside it textview I did view but I can't add to it textView inside it
fun you_color_button_1(view: View){
val view1 : View
view1 = View(this)
myLayout.addView(view1)
view1.layoutParams.height = (Height * 0.35).toInt()
view1.layoutParams.width = (Width * 0.8).toInt()
view1.x = (1+ Width*0.10).toFloat()
view1.y = (Height*0.15).toFloat()
view1.setBackgroundColor(Color.rgb(128,0,128))
val name_label1 =TextView(this)
myLayout.addView(name_label1)
la.addView(name_label1)
name_label1!!.layoutParams.height = (la.width * 0.20).toInt()
name_label1!!.layoutParams.width = (la.height * 0.10).toInt()
name_label1!!.x = (1+la.width * 0.75).toFloat()
name_label1!!.y = (la.height * 0.15).toFloat()
name_label1.text = "name"
name_label1.textSize = (Width * 0.014).toFloat()
name_label1.setTextColor(Color.WHITE)
name_label1.setTypeface(null,Typeface.BOLD)
name_label1.gravity = Gravity.CENTER
}
and too I want corner radius for View by code
When you click on a button like as You mentioned in below https://i.stack.imgur.com/UgRzA.png You should add that view as you want in your current xml and make that view's visibility Gone... Then when you click on a button on click event validate the data as you want and directly make that view's visibility to visible. I hope it helps.
initially view's visibility ->
yourView.visibility = View.GONE
btn.setOnClickListener{
YourView.visibility = View.VISIBLE
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.