本文整理汇总了Java中android.support.design.internal.BottomNavigationMenuView.getChildCount方法的典型用法代码示例。如果您正苦于以下问题:Java BottomNavigationMenuView.getChildCount方法的具体用法?Java BottomNavigationMenuView.getChildCount怎么用?Java BottomNavigationMenuView.getChildCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.design.internal.BottomNavigationMenuView
的用法示例。
在下文中一共展示了BottomNavigationMenuView.getChildCount方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: disableShiftMode
import android.support.design.internal.BottomNavigationMenuView; //导入方法依赖的package包/类
public static void disableShiftMode(BottomNavigationView navigationView) {
BottomNavigationMenuView menuView = (BottomNavigationMenuView) navigationView.getChildAt(0);
try {
Field shiftMode = menuView.getClass().getDeclaredField("mShiftingMode");
shiftMode.setAccessible(true);
shiftMode.setBoolean(menuView, false);
shiftMode.setAccessible(false);
for (int i = 0; i < menuView.getChildCount(); i++) {
BottomNavigationItemView itemView = (BottomNavigationItemView) menuView.getChildAt(i);
itemView.setShiftingMode(false);
itemView.setChecked(itemView.getItemData().isChecked());
}
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
}
示例2: centerMenuIcon
import android.support.design.internal.BottomNavigationMenuView; //导入方法依赖的package包/类
private void centerMenuIcon() {
BottomNavigationMenuView menuView = getBottomMenuView();
if (menuView != null) {
for (int i = 0; i < menuView.getChildCount(); i++) {
BottomNavigationItemView menuItemView = (BottomNavigationItemView) menuView.getChildAt(i);
AppCompatImageView icon = (AppCompatImageView) menuItemView.getChildAt(0);
FrameLayout.LayoutParams params = (LayoutParams) icon.getLayoutParams();
params.gravity = Gravity.CENTER;
menuItemView.setShiftingMode(true);
}
}
}
示例3: disableShiftMode
import android.support.design.internal.BottomNavigationMenuView; //导入方法依赖的package包/类
public static void disableShiftMode(BottomNavigationView navigationView) {
BottomNavigationMenuView menuView = (BottomNavigationMenuView) navigationView.getChildAt(0);
try {
Field shiftingMode = menuView.getClass().getDeclaredField("mShiftingMode");
shiftingMode.setAccessible(true);
shiftingMode.setBoolean(menuView, false);
shiftingMode.setAccessible(false);
for (int i = 0; i < menuView.getChildCount(); i++) {
BottomNavigationItemView itemView = (BottomNavigationItemView) menuView.getChildAt(i);
itemView.setShiftingMode(false);
itemView.setChecked(itemView.getItemData().isChecked());
}
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
}
示例4: disableShiftMode
import android.support.design.internal.BottomNavigationMenuView; //导入方法依赖的package包/类
/**
* 取消BottomNavigationView各item切换时的位移动效
*
* @param navigationView 底部导航栏视图
*/
public static void disableShiftMode(BottomNavigationView navigationView) {
BottomNavigationMenuView menuView = (BottomNavigationMenuView) navigationView.getChildAt(0);
try {
Field shiftingMode = menuView.getClass().getDeclaredField("mShiftingMode");
shiftingMode.setAccessible(true);
shiftingMode.setBoolean(menuView, false);
shiftingMode.setAccessible(false);
for (int i = 0; i < menuView.getChildCount(); i++) {
BottomNavigationItemView itemView = (BottomNavigationItemView) menuView.getChildAt(i);
itemView.setShiftingMode(false);
itemView.setChecked(itemView.getItemData().isChecked());
}
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
}
示例5: disableShiftingMode
import android.support.design.internal.BottomNavigationMenuView; //导入方法依赖的package包/类
private void disableShiftingMode() {
BottomNavigationMenuView menuView = (BottomNavigationMenuView) getChildAt(0);
try {
Field shiftingMode = menuView.getClass().getDeclaredField("mShiftingMode");
shiftingMode.setAccessible(true);
shiftingMode.setBoolean(menuView, false);
shiftingMode.setAccessible(false);
for (int i = 0; i < menuView.getChildCount(); i++) {
BottomNavigationItemView item = (BottomNavigationItemView) menuView.getChildAt(i);
item.setShiftingMode(false);
// Set the checked value so that the view will be updated.
item.setChecked(item.getItemData().isChecked());
}
} catch (NoSuchFieldException | IllegalAccessException e) {
// Do nothing if reflection fails.
}
}
示例6: getNavigationItemTitles
import android.support.design.internal.BottomNavigationMenuView; //导入方法依赖的package包/类
public static List<String> getNavigationItemTitles(BottomNavigationView navigationView) {
List<String> list = new ArrayList<>();
BottomNavigationMenuView menuView = (BottomNavigationMenuView) navigationView.getChildAt(0);
for (int i = 0; i < menuView.getChildCount(); i++) {
BottomNavigationItemView itemView = (BottomNavigationItemView) menuView.getChildAt(i);
list.add((String) itemView.getItemData().getTitle());
}
return list;
}
示例7: onCreate
import android.support.design.internal.BottomNavigationMenuView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
toolbar = (Toolbar) findViewById(R.id.toolbar);
fragmentView = findViewById(R.id.fragment);
navigationView = (BottomNavigationView) findViewById(R.id.navigation);
View title = toolbar.getChildAt(0);
if (title != null && title instanceof TextView)
FontUtils.applyTypeface((TextView) toolbar.getChildAt(0));
setSupportActionBar(toolbar);
for (int i = 0; i < navigationView.getChildCount(); i++) {
View child = navigationView.getChildAt(i);
if (child instanceof BottomNavigationMenuView) {
BottomNavigationMenuView menuView = (BottomNavigationMenuView) child;
for (int i2 = 0; i2 < menuView.getChildCount(); i2++) {
View item = menuView.getChildAt(i2);
View smallTextView = item.findViewById(android.support.design.R.id.smallLabel);
if (smallTextView != null && smallTextView instanceof TextView)
FontUtils.applyTypeface((TextView) smallTextView);
View largeTextView = item.findViewById(android.support.design.R.id.largeLabel);
if (largeTextView != null && largeTextView instanceof TextView)
FontUtils.applyTypeface((TextView) largeTextView);
}
}
}
navigationView.setOnNavigationItemSelectedListener(this);
getSupportFragmentManager().addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() {
@Override
public void onBackStackChanged() {
fragment = getSupportFragmentManager().findFragmentById(R.id.fragment);
setSelection(fragment);
}
});
if (savedInstanceState != null) {
fragment = getSupportFragmentManager().findFragmentById(R.id.fragment);
if (fragment != null) {
setSelection(fragment);
return;
}
}
toolbar.setTitle(R.string.title_articles);
fragment = new ListFragment();
getSupportFragmentManager().beginTransaction().add(R.id.fragment, fragment).commit();
}