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。

相关内容

热门资讯

重大发现!德普之星透视辅助插件... 重大发现!德普之星透视辅助插件,wepokerplus开挂,解密教程(有挂软件);致您一封信;亲爱德...
实测交流!wepoker有辅助... 实测交流!wepoker有辅助工具吗,wepoker怎么买辅助,黑科技教程(有挂技巧);大神普及一款...
一分钟快速了解!约局吧作弊脚本... 1、一分钟快速了解!约局吧作弊脚本,hhpoker真的有透视吗,2025新版技巧(有挂教程)(UU ...
避坑细节!拱趴大菠萝挂怎么安装... 避坑细节!拱趴大菠萝挂怎么安装,约局吧德州可以透视吗,揭秘教程(有挂技巧);科技安装教程;13670...
推荐一款!德扑圈透视,德普之星... 推荐一款!德扑圈透视,德普之星透视辅助软件激活码,2025新版技巧(有挂透明);建议优先通过德普之星...
技术分享!aapoker脚本怎... 技术分享!aapoker脚本怎么用,德普之星app安卓版破解版,AI教程(有挂辅助);实战中需综合运...
解密关于!德州局透视脚本免费版... 解密关于!德州局透视脚本免费版下载手机版,wepoker私人局怎么玩,玩家教程(有挂攻略);致您一封...
每日必看推荐!aapoker辅... 每日必看推荐!aapoker辅助工具安全吗,hhpoker真能买到挂吗,玩家教程(有挂技巧)1、点击...
安装程序教程!wepoker可... 安装程序教程!wepoker可以开透视吗,德普之星透视,透视教程(有挂方法);建议优先通过wepok...
1.9分钟了解!uupoker... 1.9分钟了解!uupoker透视,wpk私人辅助,透明挂教程(有挂技巧)是一款可以让一直输的玩家,...