修复小米手机首页导航栏展示不全问题
This commit is contained in:
parent
bf7bc0ed81
commit
d544de6c1d
@ -0,0 +1,65 @@
|
||||
package com.yunbao.common.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
public class NavigationBarUtils {
|
||||
|
||||
public static boolean hasNavigationBar(Activity activity) {
|
||||
boolean hasNavigationBar = false;
|
||||
int resourceId = activity.getResources().getIdentifier("config_showNavigationBar", "bool", "android");
|
||||
if (resourceId > 0) {
|
||||
hasNavigationBar = activity.getResources().getBoolean(resourceId);
|
||||
}
|
||||
|
||||
try {
|
||||
hasNavigationBar |= (Boolean) ViewConfiguration.class.getDeclaredMethod("hasNavigationBar").invoke(ViewConfiguration.get(activity));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Fall back on checking the navigation bar height, if available
|
||||
if (!hasNavigationBar && hasNavBarHeight()) {
|
||||
hasNavigationBar = true;
|
||||
}
|
||||
|
||||
return hasNavigationBar;
|
||||
}
|
||||
|
||||
public static boolean hasNavBarHeight() {
|
||||
Resources res = Resources.getSystem();
|
||||
int resourceId = res.getIdentifier("navigation_bar_height", "dimen", "android");
|
||||
if (resourceId > 0) {
|
||||
return res.getDimensionPixelSize(resourceId) > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 示例:在Activity中使用该方法
|
||||
public static boolean checkNavigationBar(Activity activity) {
|
||||
return hasNavigationBar(activity);
|
||||
}
|
||||
|
||||
public static int checkBarHeight(Activity activity) {
|
||||
int result = 0;
|
||||
Resources resources = activity.getResources();
|
||||
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
|
||||
if (resourceId > 0) {
|
||||
result = resources.getDimensionPixelSize(resourceId);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void setBarStatus(RelativeLayout rt_main_tab, Activity mContext){
|
||||
if("Xiaomi".equals(Build.BRAND)&&"2210132C".equals(Build.MODEL)){
|
||||
ViewGroup.LayoutParams params = rt_main_tab.getLayoutParams();
|
||||
params.height =params.height+ NavigationBarUtils.checkBarHeight(mContext);
|
||||
rt_main_tab.setLayoutParams(params);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -72,7 +72,6 @@ import com.yunbao.common.bean.SwTokenModel;
|
||||
import com.yunbao.common.bean.UpdataListBean;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.custom.TabButtonGroup;
|
||||
import com.yunbao.common.dialog.DebugDialog;
|
||||
import com.yunbao.common.dialog.HintDialog;
|
||||
import com.yunbao.common.dialog.InstructorOperationDialog;
|
||||
import com.yunbao.common.event.CompleteInformationEvent;
|
||||
@ -106,6 +105,7 @@ import com.yunbao.common.utils.GoogleUtils;
|
||||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.common.utils.LocationUtil;
|
||||
import com.yunbao.common.utils.MessageSayHiNotifyManager;
|
||||
import com.yunbao.common.utils.NavigationBarUtils;
|
||||
import com.yunbao.common.utils.ProcessResultUtil;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
@ -583,6 +583,8 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
showFirstLogin();
|
||||
getSwToken();
|
||||
initLogUpdate();
|
||||
//检测底部导航栏高度
|
||||
NavigationBarUtils.setBarStatus(rt_main_tab,mContext);
|
||||
}
|
||||
|
||||
private void getSwToken() {
|
||||
|
@ -31,7 +31,7 @@
|
||||
<RelativeLayout
|
||||
android:id="@+id/bottom"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true">
|
||||
|
||||
@ -151,7 +151,9 @@
|
||||
<ImageView
|
||||
android:id="@+id/btn_start"
|
||||
android:layout_width="40dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerInParent="true"
|
||||
android:onClick="mainClick"
|
||||
android:src="@mipmap/icon_middle" />
|
||||
|
Loading…
Reference in New Issue
Block a user