【问题标题】:Horizontal progress bar width in actionbar操作栏中的水平进度条宽度
【发布时间】:2013-04-03 21:43:42
【问题描述】:

我正在操作栏中显示一个水平进度条。 我的问题是进度条宽度不是操作栏宽度,而是更小(但居中)。这是正常的行为吗?我怎样才能给它屏幕宽度?

我在 onCreate 中使用它

    requestWindowFeature(Window.FEATURE_PROGRESS);

这在我的方法中

public void setShowIndeterminateProgress(boolean val) {
    setProgressBarIndeterminate(true);
    setProgressBarVisibility(val);
}

提前致谢。

【问题讨论】:

  • 您是否尝试过在模拟器和至少 2 个不同的设备中进行测试?
  • 你能放一个屏幕吗?

标签: android width android-actionbar progress


【解决方案1】:

在操作栏样式中有一个属性android:progressBarPadding。将其设置为0dip

<style name="MyActionBar" parent="@android:style/Widget.Holo.ActionBar">
    <item name="android:progressBarPadding">0dip</item>
</style>

【讨论】:

    【解决方案2】:

    您需要从菜单中删除所有项目。

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        //inflater.inflate(R.menu.main, menu);
        ActionBar actionBar = getActionBar();
        actionBar.setDisplayHomeAsUpEnabled(false);
        actionBar.setDisplayShowHomeEnabled(false);
        actionBar.setDisplayShowCustomEnabled(false);
        actionBar.setDisplayShowTitleEnabled(false);
        //actionBar.setIcon(R.drawable.ic_launcher);
    
        LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflator.inflate(R.layout.actionbar_main, null);
    
        //actionBar.setCustomView(view);
        return true;
    
    }
    

    然后创建一个带有进度条的 xml 布局。在其中宽度 =“match_parent”。 取消注释 actionBar.setCustomView 和此方法以使用您自己的自定义视图为您的 actionBar 充气。

    试一试,给我唱歌对你有用吗?

    【讨论】:

      猜你喜欢
      • 2014-04-21
      • 2017-05-26
      • 1970-01-01
      • 1970-01-01
      • 2012-12-05
      • 1970-01-01
      • 1970-01-01
      • 2014-01-25
      • 2017-09-10
      相关资源
      最近更新 更多