Android kotlin - 使用黑色透明背景的活动,并具有白色背景的SearchView
创始人
2024-08-14 11:30:11
0

在Android Kotlin中,您可以通过以下步骤实现具有黑色透明背景的活动,并具有白色背景的SearchView:

  1. 在styles.xml文件中定义一个自定义主题,将活动的背景颜色设置为黑色透明:

  1. 在活动的布局文件中,将根布局的背景颜色设置为白色:


    


  1. 在活动的onCreate方法中,将主题应用于活动:
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setTheme(R.style.AppTheme_TransparentBackground)
    setContentView(R.layout.activity_main)

    // Add other code here
}
  1. 在布局文件中添加SearchView,并将其背景颜色设置为白色:

  1. 在活动的onCreate方法中,获取SearchView的实例,并设置其背景颜色为白色:
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setTheme(R.style.AppTheme_TransparentBackground)
    setContentView(R.layout.activity_main)

    val searchView = findViewById(R.id.searchView)
    val searchPlateId = searchView.context.resources.getIdentifier("android:id/search_plate", null, null)
    val searchPlate = searchView.findViewById(searchPlateId)
    searchPlate.setBackgroundColor(Color.WHITE)

    // Add other code here
}

这样,您就可以实现具有黑色透明背景的活动,并具有白色背景的SearchView。

相关内容

热门资讯

透视辅助"德州局hh... 透视辅助"德州局hhpoker"切实真的有辅助技巧(哔哩哔哩)1、许多玩家不知道德州局hhpoker...
透视揭露"hhpok... 透视揭露"hhpoker可以控制吗"本来真的是有辅助教程(哔哩哔哩)1、完成hhpoker可以控制吗...
透视教你"wepok... 透视教你"wepoker怎么提高运气"竟然真的是有辅助app(哔哩哔哩)1、wepoker怎么提高运...
透视解密"德州透视h... 透视解密"德州透视hhpoker"其实真的有辅助挂(哔哩哔哩)德州透视hhpoker能透视中分为三种...
透视推荐"wepok... 透视推荐"wepoker永久免费脚本"真是真的是有辅助技巧(哔哩哔哩)1、wepoker永久免费脚本...
透视详情"wepok... 透视详情"wepoker怎么挂飞机"本来真的是有辅助工具(哔哩哔哩)1、首先打开wepoker怎么挂...
透视推荐"wepok... 透视推荐"wepoker黑侠辅助器"原来真的是有辅助挂(哔哩哔哩)1、玩家可以在wepoker黑侠辅...
透视辅助"约局吧是否... 透视辅助"约局吧是否有挂"确实存在有辅助app(哔哩哔哩)1、约局吧是否有挂破解器简单,约局吧是否有...
透视分享"德州局怎么... 透视分享"德州局怎么透视"一直真的是有辅助挂(哔哩哔哩)1.德州局怎么透视 选牌创建新账号,点击进入...
透视总结"wpk模拟... 透视总结"wpk模拟器是什么"本来是真的辅助神器(哔哩哔哩)wpk模拟器是什么能透视中分为三种模型:...