我使用style.I代码创建自定义标题来自http://labs.makemachine.net/2010/03/custom-android-window-title/
我还在标题栏中设置了图标,setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,R.drawable.title_logo);
可以在中间设置标题栏吗?如果可能的话,我想使用自定义样式进行设置.
编辑:我有检查代码http://andmobidev.blogspot.com/2010/01/centering-title-of-window.html
它在标题栏中没有图标时工作正常但是当设置图标我得到错误 java.lang.ClassCastException: android.widget.RelativeLayout
我有不知道窗口如何绘制标题栏,我已经检查了博客
http://android-developers.blogspot.com/2009/03/window-backgrounds-ui-speed.html
谢谢.
在我的应用程序中,我从每个活动填充标题栏标签,但活动中的文本颜色和标题栏中的文本颜色是相同的.如何将标题栏文本颜色更改为其他颜色?
我正在尝试更改我的应用程序活动菜单栏标题.我设法改变字体如下.任何人都可以帮我改变标题的名称.它可能只是一行,但我无法弄清楚.
int actionBarTitle = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
TextView actionBarTitleView = (TextView) getWindow().findViewById(actionBarTitle);
if(actionBarTitleView != null){
actionBarTitleView.setTypeface(typeFace);
}
Run Code Online (Sandbox Code Playgroud) 我正在使用Android Studio并通过搜索此处和网络其余部分提供的所有问题和答案尝试了所有可能的方法.但没有任何效果.请帮助我,我是Android的新手,非常好玩.
这是我的XML代码:
使用NoTitleBar.Fullscreen和任何其他主题.应用程序正在崩溃
<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<application
android:theme="@style/AppTheme"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:persistent="true">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
Run Code Online (Sandbox Code Playgroud)
android android-titlebar android-actionbar android-fullscreen android-studio
我试过这个用google搜索时随时可用:
android:theme="@android:style/Theme.NoTitleBar"
Run Code Online (Sandbox Code Playgroud)
但是当我应用它时,它会将整体主题改回冰淇淋前三明治.我的意思是TextView,DatePicker姜饼主题是姜饼,而不是ICS主题.有任何想法吗?
我正在尝试设计一个对话框,它看起来类似于系统对话框:

这些按钮是在应用程序标题栏上植入的吗?或者它们只是简单地放置在用户界面中?
如何在Android中集中活动的操作栏标题?
我已经在这个特定主题上看到了很多关于SO的问题.每个答案都会回到"使用自定义视图"并拥有自己的工具栏.
我找到了一个无需创建自定义视图的解决方案.
我试图将状态栏隐藏在片段中。我已经成功隐藏了工具栏,但我也只想在一个片段中隐藏状态栏。
@Override
public void onCreate(Bundle arg0) {
super.onCreate(arg0);
// requestWindowFeature(Window.FEATURE_NO_TITLE);
((HomeActivity)getActivity()).getSupportActionBar().hide();
}
Run Code Online (Sandbox Code Playgroud)
上面的代码对于隐藏工具栏工作正常
requestWindowFeature(Window.FEATURE_NO_TITLE);
Run Code Online (Sandbox Code Playgroud)
如果我requestWindowFeature在片段中onCreate(如上所述)崩溃了。
实现第二个答案后添加了三张图片
[正常屏幕] [1] [使用您的代码后,作品将有效] [2] [从全屏模式返回时[3]
Run Code Online (Sandbox Code Playgroud)[1]: https://i.stack.imgur.com/KbX4T.jpg [2]: https://i.stack.imgur.com/sSWqf.jpg [3]: https://i.stack.imgur.com/urJaK.jpg
我有一个带有 Android Studio 中默认布局的工具栏的活动,我可以通过以下方法轻松更改工具栏中的标题:
Bundle bundle = new Bundle();
bundle.putString("toolbarTitle", "A new title");
NavHostFragment
.findNavController(this)
.navigate(R.id.action_navigation_conversation_to_placeholder, bundle);
Run Code Online (Sandbox Code Playgroud)
toolbarTitle导航菜单布局中已经实现了安全参数。
但是现在我尝试更改通过上述方法打开的片段的标题,例如;
我的活动->打开->我的片段
MyFragment 更改标题
我确实知道如何在不使用导航 UI 组件的情况下更新它,但如果可能的话我想使用它们。
其他类似的问题仅与我上面提供的示例有关,即打开新片段时或建议使用不使用导航 UI 组件的典型方法,没有一个涵盖此特定场景。
android android-titlebar android-navigation android-components
我想在标题栏上添加一个按钮,但我无法成功.我已经阅读了很多关于此的文章,但它们都解释了不适合我的方式.我使用ScrollView使屏幕可滚动.但文章建议我使用线性布局.如何使其可滚动并在标题栏上有一个按钮?
这是我的xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#C0C0C0"
android:id="@+id/sw_layout">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:id="@+id/ln_layout">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft=<"@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >
.........................
.........................
.........................
</TableLayout>
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
在我的活动中,我有这个代码....
LinearLayout ln = (LinearLayout) getWindow().findViewById(R.id.ln_layout);
Button btn = new Button(this);
btn.setText("Test");
ln.addView(btn);
Run Code Online (Sandbox Code Playgroud)
但这并没有显示任何东西,它不会给我任何错误.请给我一个主意.如何将标题栏添加到标题栏?
您好,这是一个Dialog Activity.我想删除空格.我该怎么做?不幸的是,我被卡住了.谢谢你...
<style name="ThemeDialog" parent="Theme.AppCompat.Light.Dialog">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">false</item>
</style>
Run Code Online (Sandbox Code Playgroud)
<activity
android:name=".Activities.AboutActivity"
android:label="@string/hakkinda"
android:theme="@style/ThemeDialog"
android:screenOrientation="portrait"/>
Run Code Online (Sandbox Code Playgroud)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.container);
mViewPager.setAdapter(mSectionsPagerAdapter);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(mViewPager);
}
Run Code Online (Sandbox Code Playgroud)
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" …Run Code Online (Sandbox Code Playgroud)