本文整理汇总了Java中android.widget.RadioGroup.setOrientation方法的典型用法代码示例。如果您正苦于以下问题:Java RadioGroup.setOrientation方法的具体用法?Java RadioGroup.setOrientation怎么用?Java RadioGroup.setOrientation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.RadioGroup
的用法示例。
在下文中一共展示了RadioGroup.setOrientation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildButtonGroup
import android.widget.RadioGroup; //导入方法依赖的package包/类
private void buildButtonGroup() {
navButtonGroup = new RadioGroup(getContext());
navButtonGroup.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
navButtonGroup.setOrientation(LinearLayout.HORIZONTAL);
navButtonGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
RadioButton btn = (RadioButton) group.getChildAt(checkedId);
if (btn == null)
return;
// 游标划动
if (navCursor != null) {
ObjectAnimator moveAnim = ObjectAnimator.ofFloat(navCursor, "x", navCursor.getX(), btn.getX());
ValueAnimator resizeWidthAnim = ValueAnimator.ofInt(navCursor.getMeasuredWidth(), btn.getMeasuredWidth());
resizeWidthAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
navCursor.getLayoutParams().width = (Integer) animation.getAnimatedValue();
navCursor.requestLayout();
}
});
AnimatorSet set = new AnimatorSet();
set.playTogether(moveAnim, resizeWidthAnim);
set.setDuration(200);
set.start();
}
if (group.getChildAt(2) != null)
smoothScrollTo(
((checkedId > 1) ? btn.getLeft() : 0) - group.getChildAt(2).getLeft(), 0);
if (mOnCheckedChangeListener != null) {
mOnCheckedChangeListener.onCheckedChanged(group, checkedId);
}
}
});
navContainer.addView(navButtonGroup);
}