Closed hunao0221 closed 8 years ago
好的
Jaeger notifications@github.com于2016年4月14日周四 23:17写道:
目前还不行,等我有空研究下这个
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/laobie/StatusBarUtil/issues/16#issuecomment-209997450
我添加了一个方法,可以解决根布局的 首个子控件为Imageview 延伸到状态栏这种情况
/**
* 为有 ImageView 的Activity 添加半透明状态栏
*
* @param act 需要设置的Activity
* @param marginView 需要设置 margin 的 View
*/
public static void setTranslucentForImageView(Activity act, View marginView) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
act.getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
addTranslucentView(act, DEFAULT_STATUS_BAR_ALPHA);
}
ViewGroup.MarginLayoutParams vmlp = (ViewGroup.MarginLayoutParams) marginView.getLayoutParams();
vmlp.setMargins(0, getStatusBarHeight(act), 0, 0);
}
}
@SeanZom 等我测试下是否可以 可以的话我更新下
@SeanZom 那个值应该是负的= =你写错啦
哪个?没有吧,我跑过4.4和5.0的
@SeanZom 这个
没有写错
@SeanZom 这个值正的话 是往下移啊 你跑了什么版本的?
原来是使用场景的问题,不是谁对谁错的问题。我一阵传个我的使用例子,现在不在电脑旁。
好的
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/iv_header_img"
android:tag="这个是 头部延伸到状态栏的Image"
.../>
<Button
android:id="@+id/btn_back"
android:tag="这个是 marginView"
.../>
</RelativeLayout>
哦哦 这样的 ,marginView 不是必须的咯 刚才弄错了 不好意思
你有没有QQ或者其他联系方式方便点沟通。如果要继续探究的话。marginView确实不是必须,但是ImageView依然是可以延伸到状态栏啊,5.0和4.4.4的我都试过
@hunao0221 最新的1.2.0 版本已经支持这个了,可以看看,issuse 我关闭了哈
目前还不行,等我有空研究下这个