我在我的项目中使用了actionbarshearlock库。 我想要操作栏是透明的。 如何做到这一点? 在此先感谢。actionbarshearlock活动中的透明操作栏
回答
不使用actionbarshearlock:
刚添加此行:requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
在onCreate
setContentView(R.Layout.Test)
这行之前给你TRANSPARENT ActionBar
getActionBar().setBackgroundDrawable(
getResources().getDrawable(R.drawable.ab_bg_black));
,如:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
setContentView(R.layout.activity_main);
getActionBar().setBackgroundDrawable(
getResources().getDrawable(R.drawable.ab_bg_black));
}
为R.drawable.ab_bg_black只是像string.xml添加绘制颜色:
<drawable name="ab_bg_black">#80000000</drawable>
同样的方式使用actionbarshearlock:
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(SampleList.THEME); //Used for theme switching in samples
requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
super.onCreate(savedInstanceState);
setContentView(R.layout.overlay);
//Load partially transparent black background
getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.ab_bg_black));
}
编辑:Start listview After Actionbar.
如果您使用actionbarshearlock然后就去做象下面这样:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="?actionBarSize" >
</ListView>
</LinearLayout>
Dhaval Sodha帕尔马非常感谢你保存我的日子 一个问题更多我有一个清单,我的清单应该在操作栏下面 – 2013-04-08 07:23:22
@ImranKhan:我的荣幸.... – 2013-04-08 07:34:55
有一个问题更多我有一个清单,我的清单应该在操作栏下方如何操作 – 2013-04-08 08:34:41
试试这个代码,但我不知道这正是你所需要的:
bar.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
- 1. 使用操作栏的活动透明背景
- 2. Android - 操作栏不透明
- 3. 操作栏透明度
- 4. 透明操作栏和状态栏
- 5. 透明的Android上下文操作栏
- 6. 拆分操作栏不透明
- 7. 如何使操作栏透明
- 8. 半透明PagerTabStrip与操作栏覆盖
- 9. 具有透明背景和动作栏的Android活动?
- 10. 不可能在活动图中添加不透明操作
- 11. 通过透明的透明SurfaceView活动
- 12. 如何制作不透明的活动?
- 13. 活动crashesh而透明的活动
- 14. Android的明星,从操作栏另一个活动
- 15. 透明状态栏与操作栏重叠
- 16. 活动的透明度
- 17. 主要活动的隐藏操作栏
- 18. Android:透明活动不起作用
- 19. 操作栏和导航抽屉 - 带活动/片段的滑动操作栏
- 20. 半透明的黑色状态栏没有工具栏或操作栏
- 21. 安卓活动透明度
- 22. Android独立透明活动
- 23. Android显示透明活动
- 24. 透明Android活动问题
- 25. 如何使活动透明
- 26. 活动中的透明矩形
- 27. 按片段设置的透明操作栏
- 28. QuickPic如何做一个半透明的操作栏?
- 29. 操作栏填充背景错误的透明图标像素
- 30. 如何使我的自定义操作栏透明
@Imram汗:检查我的编辑答案:http://stackoverflow.com/a/15873047/1168654 – 2013-04-08 10:14:43