API 级别 11+ 之后,进度对话框未在 ActionBarSherlock 中对齐

2024-06-19

在我的项目中,我添加了 Library ActionBar Sherlock 并为我的项目创建自定义主题。

我已经创建了自定义主题here http://jgilfelt.github.io/android-actionbarstylegenerator/。 但是应用主题后,我的进度对话框未对齐(意味着未显示在屏幕中央)。

请不要在 API 级别 11 或更高版本中出现此问题。
这里我附上了运行 OS 4.2.2 的模拟器的屏幕截图。

我无法弄清楚这个问题......

截屏 ::

MyCustomTheme ::(值文件夹)

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">


    <style name="Theme.Custom_ThemeSherlockLight" parent="@style/Theme.Sherlock.Light">
        <item name="actionBarItemBackground">@drawable/selectable_background_exampthemesherlocklightle</item>
        <item name="popupMenuStyle">@style/PopupMenu.Custom_ThemeSherlockLight</item>
        <item name="dropDownListViewStyle">@style/DropDownListView.Custom_ThemeSherlockLight</item>
        <item name="actionBarTabStyle">@style/ActionBarTabStyle.Custom_ThemeSherlockLight</item>
        <item name="actionDropDownStyle">@style/DropDownNav.Custom_ThemeSherlockLight</item>
        <item name="actionBarStyle">@style/ActionBar.Solid.Custom_ThemeSherlockLight</item>
        <item name="actionModeBackground">@drawable/cab_background_top_exampthemesherlocklightle</item>
        <item name="actionModeSplitBackground">@drawable/cab_background_bottom_exampthemesherlocklightle</item>
        <item name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Custom_ThemeSherlockLight</item>
    </style>

    <style name="ActionBar.Solid.Custom_ThemeSherlockLight" parent="@style/Widget.Sherlock.Light.ActionBar.Solid">
        <item name="background">@drawable/ab_solid_exampthemesherlocklightle</item>
        <item name="backgroundStacked">@drawable/ab_stacked_solid_exampthemesherlocklightle</item>
        <item name="backgroundSplit">@drawable/ab_bottom_solid_exampthemesherlocklightle</item>
        <item name="progressBarStyle">@style/ProgressBar.Custom_ThemeSherlockLight</item>
    </style>

    <style name="ActionBar.Transparent.Custom_ThemeSherlockLight" parent="@style/Widget.Sherlock.Light.ActionBar">
        <item name="background">@drawable/ab_transparent_exampthemesherlocklightle</item>
        <item name="progressBarStyle">@style/ProgressBar.Custom_ThemeSherlockLight</item>
    </style>

    <style name="PopupMenu.Custom_ThemeSherlockLight" parent="@style/Widget.Sherlock.Light.ListPopupWindow">
        <item name="android:popupBackground">@drawable/menu_dropdown_panel_exampthemesherlocklightle</item>
    </style>

    <style name="DropDownListView.Custom_ThemeSherlockLight" parent="@style/Widget.Sherlock.Light.ListView.DropDown">
        <item name="android:listSelector">@drawable/selectable_background_exampthemesherlocklightle</item>
    </style>

    <style name="ActionBarTabStyle.Custom_ThemeSherlockLight" parent="@style/Widget.Sherlock.Light.ActionBar.TabView">
        <item name="android:background">@drawable/tab_indicator_ab_exampthemesherlocklightle</item>
    </style>

    <style name="DropDownNav.Custom_ThemeSherlockLight" parent="@style/Widget.Sherlock.Light.Spinner.DropDown.ActionBar">
        <item name="android:background">@drawable/spinner_background_ab_exampthemesherlocklightle</item>
        <item name="android:popupBackground">@drawable/menu_dropdown_panel_exampthemesherlocklightle</item>
        <item name="android:dropDownSelector">@drawable/selectable_background_exampthemesherlocklightle</item>
    </style>

    <style name="ProgressBar.Custom_ThemeSherlockLight" parent="@style/Widget.Sherlock.Light.ProgressBar.Horizontal">
        <item name="android:progressDrawable">@drawable/progress_horizontal_exampthemesherlocklightle</item>
    </style>

    <style name="ActionButton.CloseMode.Custom_ThemeSherlockLight" parent="@style/Widget.Sherlock.Light.ActionButton.CloseMode">
        <item name="android:background">@drawable/btn_cab_done_exampthemesherlocklightle</item>
    </style>

    <!-- this style is only referenced in a Light.DarkActionBar based theme -->
    <style name="Theme.Custom_ThemeSherlockLight.Widget" parent="@style/Theme.Sherlock">
        <item name="popupMenuStyle">@style/PopupMenu.Custom_ThemeSherlockLight</item>
        <item name="dropDownListViewStyle">@style/DropDownListView.Custom_ThemeSherlockLight</item>
    </style>

    <style name="Theme.Sherlock.Translucent" parent="@style/Theme.Sherlock">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowIsFloating">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:backgroundDimEnabled">false</item>
        <item name="android:backgroundDimEnabled">true</item>
    </style>

    <style name="Theme.Translucent" parent="@android:style/Theme.Translucent">
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:backgroundDimEnabled">true</item>
    </style>

</resources>

AndroidManifest.xml::

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.testproject"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="7"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme.Custom_ThemeSherlockLight" >
        <activity
            android:name="com.example.testproject.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

MainActivity.java

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ProgressDialog pDialog=new ProgressDialog(this);
        pDialog =ProgressDialog.show(this,null, "Please Wait..", true);
        pDialog.setContentView(R.layout.progress);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

进度.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="130dp"
    android:layout_height="80dp"
    android:background="@android:color/transparent"
    android:gravity="center"
    android:orientation="vertical" >

    <ProgressBar
        android:id="@+id/progress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dip"
        android:gravity="center"
        android:text="Please wait.."
        android:textColor="@color/black" />

</LinearLayout>

请更改以下代码行

进度.xml 文件

android:layout_width="130dp"
android:layout_height="80dp"

to

android:layout_width="match_parent"
android:layout_height="match_parent"

它现在应该显示在屏幕中央。

希望这可以帮助!

Edit:请将TextView的layout_width属性更改为“wrap_content”。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

API 级别 11+ 之后,进度对话框未在 ActionBarSherlock 中对齐 的相关文章

随机推荐

  • 如何获取 git 存储库中所有文件的计数?

    如何获取 git 存储库中当前所有文件的计数 您可以使用以下命令获取 git 存储库中所有跟踪文件的计数 git ls files wc l 命令分解 The git ls files命令本身打印出存储库中所有跟踪文件的列表 每行一个 Th
  • 解析函数是否异步传递给 Promise 执行器?

    我有以下代码 function myPromiseFunc return new Promise resolve gt resolve Promise resolve 123 据我们所知Promise resolve方法立即用普通值解析 P
  • Struts2 中有多种结果类型?

    我有一个使用 Tiles 的 Struts2 应用程序 如何在操作映射中获取多种结果类型 因为我需要将de输出设置为JSON数据 并且同时Tiles 我努力了
  • 网站可以检测您何时将 Selenium 与 chromedriver 结合使用吗?

    我一直在使用 Chromedriver 测试 Selenium 我注意到有些页面可以检测到您正在使用 Selenium 即使根本没有自动化 即使我只是通过 Selenium 使用 Chrome 手动浏览 Xephyr https en wi
  • 如何使用 Spring Security 手动注销用户?

    也许答案很简单 如何在 Spring Security 中手动注销当前登录的用户 拨打电话是否足够 SecurityContextHolder getContext getAuthentication setAuthenticated fa
  • VSTS部署IIS应用程序winrm并更改appsettings.json

    我正在使用 部署 IIS 应用程序 winrm 任务在另一台计算机上部署 IIS 应用程序 此任务部署 zip 文件 在此 zip 中有一个 appsettings json 其变量以下划线开头和结尾 我需要替换每个环境的 appsetti
  • 删除 IF ELSE 语句中的临时表

    我在这里面临僵局 问题是我必须更改使用 3 个不同临时表的过程 为了便于对话 让我们将它们命名为 temptable1 temptable2 temptable3 我无法在这里复制 粘贴整个过程 但总体思路是这样的 原始过程 procedu
  • 为什么 JDOM 的 getChild() 方法返回 null?

    我正在做一个关于 html 文档操作的项目 我想要现有 html 文档中的正文内容将其修改为新的 html 现在我正在使用 JDOM 我想在我的编码中使用 body 元素 为此 我在编码中使用了 getChild body 但它向我的程序返
  • TListView 中的中心子项目图像

    Is it possible to fix the drawing of subitem images in a TListView so that they are not cut off on the left hand side as
  • 读取完 JSON 内容和意外标记后遇到的其他文本(在我的 json 中)

    我使用 JSON Net 创建的 json feed 遇到一些问题 当我尝试解析它时 它给了我 读取完 JSON 内容后遇到的附加文本 路径 第 17 行 位置 4 我尝试用以下方法验证它http json parser online fr
  • 用于清除工作空间和转储存储的 R 全局函数

    我希望创建一个全局函数来清除我的工作区并转储我的内存 我将我的函数称为 cleaner 并希望它执行以下代码 remove list ls gc 我尝试在全局环境中创建该函数 但是当我运行它时 控制台仅打印该函数的文本 在我要获取的函数文件
  • 有没有办法阻止 SQL Express 2008 空闲?

    我使用 SQL Express 2008 作为 Web 应用程序的后端 问题是 Web 应用程序是在工作时间使用的 因此有时在午餐或休息时间 如果 20 分钟内没有用户登录 SQL Express 将进入空闲状态模式并释放其缓存 我知道这一
  • 使用 TABLE_DATE_RANGE 时如何获取表名称

    我想使用 TABLE DATE RANGE 获取每日统计信息 如下所示 Select count tableName FROM TABLE DATE RANGE appengine logs appengine googleapis com
  • C++ 中带逗号的表达式的执行顺序 [重复]

    这个问题在这里已经有答案了 我的理解是这个词j i将在之前执行 i在声明中 j i i C 标准是否保证j i将在之前执行 i在循环 for auto i std next begin j begin i end j i i 逗号运算符引入
  • 如何将 pygame Surface 转换为 PIL 图像?

    我正在使用 PIL 来透视地变换屏幕的一部分 原始图像数据是一个 pygame Surface 需要转换为 PIL 图像 因此我发现了 pygame 的 tostring 函数就是为了这个目的而存在的 然而结果看起来很奇怪 见附图 这段代码
  • Razor 视图类型不继承自“System.Web.WebPages.WebPage”

    我在配置 ASP NET MVC 应用程序时遇到问题 HttpException 0x80004005 Type ASP Page Currency Index cshtml does not inherit from System Web
  • Ansible - 任务系列 1 逆序

    我想创建两本剧本 一本用于停止环境 另一本用于启动它 环境的一部分是 RabbitMQ 集群 对于其停止 启动顺序非常重要 特别是最后一个停止的节点需要是第一个启动的节点 我想知道是否有一种方法可以指定针对组运行任务的相反顺序 这样我就可以
  • 变量前面的@是什么意思? [复制]

    这个问题在这里已经有答案了 可能的重复 参考 这个符号在 PHP 中意味着什么 https stackoverflow com questions 3737139 reference what does this symbol mean i
  • localStorage 获取 NULL?

    我不知道为什么 因为我之前已经这样做过并且工作正常 我认为这可能是因为浏览器问题 错误 localStorage setItem foo bar alert localStorage getItem foo 我使用的是 Firefox 3
  • API 级别 11+ 之后,进度对话框未在 ActionBarSherlock 中对齐

    在我的项目中 我添加了 Library ActionBar Sherlock 并为我的项目创建自定义主题 我已经创建了自定义主题here http jgilfelt github io android actionbarstylegener