Chrome和Firefox 4以及其他应用程序现在将其部分用户界面放在标题栏中.在Windows中,操作系统通常控制整个标题栏.应用程序可以通过删除操作系统标题栏并绘制"假"标题栏(如WinAmp)来创建自定义标题栏,但只有操作系统知道如何绘制标题栏的非自定义元素(例如,关闭/最小化/ Maximize),因操作系统版本而异.
通过什么机制,Chrome和Firefox等应用程序与操作系统"共享"标题栏(在保留原始操作系统视觉主题的同时将自定义元素放在标题栏中)?
在Chrome中,标签会侵占标题栏,因此标题文字空间不足.
我正在开发一个Android应用程序,我有一个AlertDialog子类.我想在对话框的标题区域的右侧放置2个ImageButtons(类似于Activity中的ActionBar).我正在使用setCustomTitle()执行此操作,它将标题区域替换为我自己创建的自定义视图.这工作正常,但我的自定义标题区域的样式与标准标题样式(高度,颜色,分隔符等)不同.
我的问题是:由于理解风格因操作系统版本和制造商而异,我如何在对话框中设置自定义标题的样式,以便它与其他AlertDialogs的标准标题样式相匹配?
这是带有标准样式的anAlertDialog图像(这是来自ICS,但我希望能够匹配任何变体 - 而不是这种特殊的样式)
这是一个带有自定义标题和按钮的AlertDialog图像(注意标题高度和颜色与标准对话框的不匹配)
编辑:我不能只将ImageButtons添加到标准标题视图,因为我无法访问它. 如果你知道(可靠的,非黑客的)方法让我在标准标题区域添加按钮,我也会接受.
我如何在alertDialog中包含自定义标题栏?我知道android sdk提供了setCustomTitle方法,但它不起作用
编辑:
AlertDialog alert = new AlertDialog.Builder(this).setTitle("Test").setMessage("hello").show();
View view=alert.getLayoutInflater().inflate(R.layout.titlebar, null);
alert.setCustomTitle(view);
Run Code Online (Sandbox Code Playgroud)
但上面的代码不起作用
注意:
我不是在寻找自定义对话框,而是只想使其标题布局自定义.如下所示
我试图设置一个自定义标题栏包括微调器对象,但每次它给我一个名为"你不能将自定义标题与其他标题功能组合"的异常.我按网站搜索找到一个解决方案网站,并且我按照网络上的说明正确地做了一切,但异常从未消失.我心中有一个非常愚蠢的问题,它可能与android 3.0有关吗?我正在开发3.0版(蜂窝).我不知道该怎么办.
谢谢adamp,我在你的指导下做到了.这是一个带有微调器示例的简单操作栏.可能会帮助面临类似问题的人.
super.onCreate(savedInstanceState);
setContentView(R.layout.screens);
ActionBar bar = getActionBar();
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
bar.setListNavigationCallbacks(new SpinnerAdapter(this, android.R.layout.simple_dropdown_item_1line, EczaneMgr.getInstance(this).getEczaneListAsSpinner()),
new OnNavigationListener() {
@Override
public boolean onNavigationItemSelected(int position, long itemId) {
Log.e("item position",String.valueOf(position));
return true;
//do whatever want to do...
}
}
);
Run Code Online (Sandbox Code Playgroud) 我有一个项目,我在其中设置:
onCreate方法中的代码是这样的:
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
...
Run Code Online (Sandbox Code Playgroud)
使用以前的设置,一切正常!但是,如果我将minSdkVersion设置为11或更高,则会发生以下异常:
android.util.AndroidRuntimeException: You cannot combine custom titles with other title features
Run Code Online (Sandbox Code Playgroud)
我不明白为什么这只是改变minSdkVersion.我在这个网站上对这个问题大加红了.我尝试过设置:
由于我只使用API 11提供的功能,我想在加载商店App之前将minSdk设置为11.我能怎么做 ??我需要帮助
编辑:使用清单中的minSdkVersion = 10和Theme.NoTitleBar,会发生同样的错误.删除它,一切都像以前一样.当API为11或更高时,任何人都可以提供工作代码(清单和活动代码)来设置自定义标题吗?太多了
android titlebar tabactivity custom-titlebar android-tabactivity
我知道这个问题已被提出,但我无法弄清楚如何让它运作起来.我想改变标题栏的背景.
我不想改变我的应用程序或我的背景风格.
我在这个网站上关注了各种帖子,但似乎都没有给出令人满意的结果.
我认为它就像设置一样简单
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowTitleBackgroundStyle">@drawable/backrepeat</item>
</style>
Run Code Online (Sandbox Code Playgroud)
在styles.xml中
然而,这并没有给出任何改变.
对于completness,下面是我的backrepeat文件
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/bg_diamonds"
android:tileMode="repeat"
android:dither="true"
/>
Run Code Online (Sandbox Code Playgroud)
和manifest.xml中的代码
<application
android:allowBackup="true"
android:icon="@drawable/maxmm_start_icon"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
Run Code Online (Sandbox Code Playgroud) 我为我的应用程序设计了一个自定义标题栏.它也适合我.但有一个问题.在我的自定义标题栏覆盖之前,可以看到默认标题(仅一秒钟).有没有解决方案来禁用android提供的默认标题栏?
我的代码就像......
res/layout中的window_title.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myTitle"
android:text="custom title bar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="@color/titletextcolor"
android:gravity ="center"/>
Run Code Online (Sandbox Code Playgroud)
res/values中的color.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="customTheme" parent="android:Theme">
<item name="android:windowTitleBackgroundStyle">@style/WindowTitleBackground </item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
res/values中的styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="titlebackgroundcolor">#303010</color>
<color name="titletextcolor">#FFFF00</color>
</resources>
Run Code Online (Sandbox Code Playgroud)
res/values中的themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="WindowTitleBackground">
<item name="android:background">@color/titlebackgroundcolor</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
我还更新了我的manifest.xml的活动
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.title"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<application
android:icon="@drawable/ic_launcher"
android:theme="@style/customTheme"
android:label="@string/app_name" >
<activity
android:name=".CustomTitleActivity"
android:theme="@style/customTheme" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" …
Run Code Online (Sandbox Code Playgroud) 我的问题就是自定义标题栏 - 系统标题栏短暂显示的问题?
但我无法达到和@Jerry在最佳答案上所写的相同的结果."当我切换到使用主题来告诉框架我不想要一个标题时,问题消失了,我现在直接在第一次加载时看到我自己的标题"
我的代码:
表现:
<?xml version="1.0" encoding="UTF-8"?>
<manifest android:versionCode="3" android:versionName="1.0.2"
package="androidhive.dashboard" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="8"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application android:icon="@drawable/icone" android:label="@string/app_name">
<activity
android:name="com.androidhive.dashboard.SplashScreen"
android:theme="@android:style/Theme.NoTitleBar"
android:label="@string/app_name"
android:windowSoftInputMode="stateHidden|adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/SplashTheme"
>
<ImageView
android:id="@+id/splashscreen_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
android:contentDescription="Splash"
android:scaleType="centerCrop"
android:src="@drawable/splash"
style="@style/SplashTheme" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
样式:
<style name="SplashTheme" parent="@android:Theme.Black">
<item name="android:windowNoTitle">true</item>
<item name="android:background">@drawable/splash</item>
</style>
Run Code Online (Sandbox Code Playgroud)
SplashScreen.java
public class SplashScreen extends Activity implements Runnable{
@Override
protected void onCreate(Bundle savedInstanceState) { …
Run Code Online (Sandbox Code Playgroud) 使用Delphi我想在边框图标按钮上添加另一个按钮; 关闭,最大化,最小化.关于如何做到这一点的任何想法?
嗨,我想在我的应用程序中创建一个带导航抽屉的自定义ActionBar.在那里我想显示在右侧的圆圈内登录我的应用程序的人的脸.和左侧的导航栏.
.
它之前没有使用导航抽屉.