【问题标题】:How to change the customize Window title bar and its icon for multiple activities如何为多个活动更改自定义窗口标题栏及其图标
【发布时间】:2014-10-07 10:45:41
【问题描述】:

我可以通过以下链接自定义窗口标题栏及其图标:-

http://androidcodesnippetsblog.blogspot.in/2013/03/custom-window-title-bar-in-android.html

但是我希望在同一个项目中运行的不同活动有不同的标题。有没有办法从一个特定的 xml 修复为多个活动的标题栏和图标。

【问题讨论】:

    标签: android user-interface android-activity


    【解决方案1】:

    只需在自定义布局中设置 imageview 和 textview id 并在特定 Activity 中动态设置其值

    ImageView image=(Imageview)getWindow().findViewById(your image view id);
    TextView title=(Textview)getWindow().findViewById(your image view id);
    

    设置image.setImageResource(...);title.settext(title);

    就是这样……

    【讨论】:

    • 谢谢!!这对我真的很有帮助!! :)
    【解决方案2】:

    不要让应用程序标签上的主题改为您的活动。例如:

          <activity
            android:theme="@style/themeForAcitivy"
            android:name="MyActivity">
          </activity>
    

    您也可以在每个活动上调用 getActionBar().setCustomView(R.layout.myCustomBar) 来创建自定义的 ActionBar 视图,如果这也适合您的话。

    【讨论】:

      猜你喜欢
      • 2020-01-09
      • 1970-01-01
      • 2011-07-03
      • 1970-01-01
      • 1970-01-01
      • 2018-02-25
      • 2022-08-15
      • 1970-01-01
      • 2014-07-05
      相关资源
      最近更新 更多