Android: How to display centered ProgressBar in support ActionBar

时间:2017-08-30 20:45:47

标签: android android-actionbar

Trying to display a progress bar inside my activity's title bar, and I'm struggling how to make it neatly centered.

My code so far:

Progressbar layout:

#expr SaveToFile(AddBackslash(SourcePath) + "Preprocessed.iss")

Activity layout:

#define GetDllSource(Name) \
    FileExists(Name + "_Secure\" + Name + ".dll") ? \
        Name + "_Secure\" + Name + ".dll" : Name + ".dll"

[Files]
Source: {#GetDllSource("MyClass")}; DestDir: "{app}"
Source: {#GetDllSource("MyClass2")}; DestDir: "{app}"

Java code:

#pragma parseroption -p-

; For given DLL, return path to secured DLL, if exists, otherwise return the DLL itself
#define GetDllSource(FileName) \
    Local[0] = ExtractFileName(FileName), \
    Local[1] = Pos(".", Local[0]), \
    Local[2] = Local[1] > 0 ? Copy(Local[0], 1, Local[1] - 1) : Local[0], \
    Local[3] = ExtractFilePath(FileName), \
    Local[4] = Local[3] + "\\" + Local[2] + "_Secure\\" + Local[0], \
    FileExists(Local[4]) ? Local[4] : FileName

; For DLLs, returns [Files] section entry, skip other files
#define FileEntry(Source) \
    (ExtractFileExt(Source) != "dll") ? \
        "" : "Source: " + GetDllSource(Source) + "; DestDir: {app}\n"

; If the directory entry is folder, call ProcessFolder.
; If it is a file, call FileEntry
#define ProcessFile(Source, FindResult, FindHandle) \
    FindResult \
        ? \
            Local[0] = FindGetFileName(FindHandle), \
            Local[1] = Source + "\\" + Local[0], \
            (Local[0] != "." && Local[0] != ".." \
                ? (DirExists(Local[1]) ? ProcessFolder(Local[1]) : FileEntry(Local[1])) \
                : "") + \
            ProcessFile(Source, FindNext(FindHandle), FindHandle) \
        : \
            ""

; If the folder is not _Secure, process its files and subfolders
#define ProcessFolder(Source) \
    (Pos("_Secure", ExtractFileName(Source)) > 0) ? \
        "" : \
        (Local[0] = FindFirst(Source + "\\*", faAnyFile), \
        ProcessFile(Source, Local[0], Local[0]))

#pragma parseroption -p+

[Files]
; Process this folder for DLLs and subfolders (can be changed for a real path)
#emit ProcessFolder(".")

pretty straightforward, but results are quite horrible, the whole thing just looks weird...

Screenshot of uncentered progressbar

Same thing in layout inspector

Screenshot of layout inspector with uncentered progressbar

Any idea how to proceed?

I don't need any other actionbar features besides menu and back arrow. Would it be possible to display these controls separately with expected behaviour? (which is quite complex, especially for overflow menu)

Or is it possible to alter ActionBar style so both sides have same size (AND padding/margin)?

Ideas?

1 个答案:

答案 0 :(得分:0)

okey .. check my answer on this question .. i think it might be helpful for you Title bar