本文整理汇总了Java中android.widget.LinearLayout.getChildAt方法的典型用法代码示例。如果您正苦于以下问题:Java LinearLayout.getChildAt方法的具体用法?Java LinearLayout.getChildAt怎么用?Java LinearLayout.getChildAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.LinearLayout
的用法示例。
在下文中一共展示了LinearLayout.getChildAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invalidateActivated
import android.widget.LinearLayout; //导入方法依赖的package包/类
private TextView invalidateActivated(View view, final boolean isActive, final boolean noArrowIfAlone, final boolean allowArrowVisible) {
int contentColor = isActive ? contentColorActivated : contentColorDeactivated;
LinearLayout child = (LinearLayout) view;
TextView tv = (TextView) child.getChildAt(0);
tv.setTextColor(contentColor);
ImageView iv = (ImageView) child.getChildAt(1);
iv.setColorFilter(contentColor, PorterDuff.Mode.SRC_IN);
if (noArrowIfAlone && getChildCount() == 1)
iv.setVisibility(View.GONE);
else if (allowArrowVisible)
iv.setVisibility(View.VISIBLE);
else
iv.setVisibility(View.GONE);
return tv;
}
示例2: setStars
import android.widget.LinearLayout; //导入方法依赖的package包/类
@BindingAdapter({"stars"})
public static void setStars(LinearLayout linearLayout, float rating) {
Context context = linearLayout.getContext();
int color = AssetHelper.getColorFromScore(rating);
// Child 0 is the textView with the written score
Drawable roundedBackground = ContextCompat.getDrawable(context, R.drawable.rounded_edges);
roundedBackground.setColorFilter(color, PorterDuff.Mode.ADD);
linearLayout.getChildAt(0).setBackground(roundedBackground);
int nStars = Math.round(rating);
for (int i = 1; i <= nStars; ++i) {
ImageView imageView = (ImageView) linearLayout.getChildAt(i);
imageView.setColorFilter(color);
}
}
示例3: selectInLayout
import android.widget.LinearLayout; //导入方法依赖的package包/类
private View selectInLayout(LinearLayout layout, Object tag) {
View selected = null;
int count = layout.getChildCount();
for (int i = 0; i<count; i++) {
View v = layout.getChildAt(i);
if (tag == v.getTag()) {
selected = v;
} else {
v.setVisibility(View.GONE);
}
}
if (selected != null) {
selected.setVisibility(View.VISIBLE);
}
return selected;
}
示例4: initPoint
import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
* 初始化底部小点
*/
private void initPoint(int views) {
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.point);
points = new ImageView[views];
//循环取得小点图片
for (int i = 0; i < views; i++) {
//得到一个LinearLayout下面的每一个子元素
points[i] = (ImageView) linearLayout.getChildAt(i);
//默认都设为灰色
points[i].setEnabled(true);
//给每个小点设置监听
// points[i].setOnClickListener(this);
//设置位置tag,方便取出与当前位置对应
points[i].setTag(i);
}
//设置当面默认的位置
currentIndex = 0;
//设置为白色,即选中状态
points[currentIndex].setEnabled(false);
}
示例5: init
import android.widget.LinearLayout; //导入方法依赖的package包/类
private void init(Context context){
this.mContext=context;
LayoutInflater inflater=LayoutInflater.from(context);
inflater.inflate(R.layout.call_select_dialog, this);
if(list!=null){
setList(list, title);
}
else if(this.title!=null){
LinearLayout v=(LinearLayout) getChildAt(0);
LinearLayout v1=(LinearLayout) v.getChildAt(0);
titleText=(TextView)v1.getChildAt(0);
closeBT=(ImageView) v1.getChildAt(1);
closeBT.setOnTouchListener(defaultTounchListener);
titleText.setText(this.title);
}
}
示例6: setContent
import android.widget.LinearLayout; //导入方法依赖的package包/类
private void setContent() {
if (!isShowBubble() && !isMiddleItem()) {
return;
}
LinearLayout bodyContainer = (LinearLayout) view.findViewById(R.id.message_item_body);
// 调整container的位置
int index = isReceivedMessage() ? 0 : 3;
if (bodyContainer.getChildAt(index) != contentContainer) {
bodyContainer.removeView(contentContainer);
bodyContainer.addView(contentContainer, index);
}
if (isMiddleItem()) {
setGravity(bodyContainer, Gravity.CENTER);
} else {
if (isReceivedMessage()) {
setGravity(bodyContainer, Gravity.LEFT);
contentContainer.setBackgroundResource(leftBackground());
} else {
setGravity(bodyContainer, Gravity.RIGHT);
contentContainer.setBackgroundResource(rightBackground());
}
}
}
示例7: onMeasure
import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
* 设置子View和自己的宽和高
* @param widthMeasureSpec
* @param heightMeasureSpec
*/
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (!mMeasureOnce) {
//初始化控件
mWapper =(LinearLayout)getChildAt(0);
mMenu = (ViewGroup)mWapper.getChildAt(0);
mContent =(ViewGroup)mWapper.getChildAt(1);
mMenuWidth = mScreenWidth - mMenuRightPadding;
mMenu.getLayoutParams().width = mMenuWidth;
mContent.getLayoutParams().width = mScreenWidth;
//mCanScrollArea = getMeasuredWidth()/5;
mCanScrollArea = 40;
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
示例8: addCrumb
import android.widget.LinearLayout; //导入方法依赖的package包/类
public void addCrumb(@NonNull Crumb crumb, boolean refreshLayout) {
LinearLayout view = (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.bread_crumb, this, false);
view.setTag(mCrumbs.size());
view.setOnClickListener(this);
ImageView iv = (ImageView) view.getChildAt(1);
if (Build.VERSION.SDK_INT >= 19 && iv.getDrawable() != null) {
iv.getDrawable().setAutoMirrored(true);
}
iv.setVisibility(View.GONE);
mChildFrame.addView(view, new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
mCrumbs.add(crumb);
if (refreshLayout) {
mActive = mCrumbs.size() - 1;
requestLayout();
}
invalidateActivatedAll();
}
示例9: getDesiredHeight
import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
* Calculates desired height for layout
*
* @param layout the source layout
* @return the desired layout height
*/
private int getDesiredHeight(LinearLayout layout) {
if (layout != null && layout.getChildAt(0) != null) {
itemHeight = layout.getChildAt(0).getMeasuredHeight();
}
int desired = itemHeight * visibleItems - itemHeight * ITEM_OFFSET_PERCENT / 50;
return Math.max(desired, getSuggestedMinimumHeight());
}
示例10: getDesiredHeight
import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
* Calculates desired height for layout
*
* @param layout
* the source layout
* @return the desired layout height
*/
private int getDesiredHeight(LinearLayout layout) {
if (layout != null && layout.getChildAt(0) != null) {
itemHeight = layout.getChildAt(0).getMeasuredHeight();
}
int desired = itemHeight * visibleItems - itemHeight * ITEM_OFFSET_PERCENT / 50;
return Math.max(desired, getSuggestedMinimumHeight());
}
示例11: removeChild
import android.widget.LinearLayout; //导入方法依赖的package包/类
public void removeChild(String childId) {
int containerCount = linearLayout.getChildCount();
LinearLayout lastContainer = null;
List<LinearLayout> containerList = new ArrayList<>();
for (int i = 0; i < containerCount; i++) {
LinearLayout container = (LinearLayout) linearLayout.getChildAt(i);
containerList.add(container);
}
for (LinearLayout resultContainer : containerList) {
if (lastContainer == null) {
LinearLayout child = (LinearLayout) resultContainer.findViewWithTag(childId);
if (child != null) {
resultContainer.removeView(child);
if (resultContainer.getChildCount() == 0) {
linearLayout.removeView(resultContainer);
break;
} else {
lastContainer = resultContainer;
}
}
} else {
View view = resultContainer.getChildAt(0);
resultContainer.removeView(view);
lastContainer.addView(view);
if (resultContainer.getChildCount() == 0) {
linearLayout.removeView(resultContainer);
break;
} else {
lastContainer = resultContainer;
}
}
}
}
示例12: onMeasure
import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
* 将记录的值设置到控件上,并只让控件设置一次
* @param widthMeasureSpec
* @param heightMeasureSpec
*/
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if(!isonce) {
mParentView = (LinearLayout) this.getChildAt(0);
mTopView = (ViewGroup) mParentView.getChildAt(0);
mTopView.getLayoutParams().height = mTopViewHeight;
isonce=true;
}
}
示例13: dismiss
import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
* Animate the views too look more lively
*/
public void dismiss()
{
LinearLayout layout = (LinearLayout) getChildAt(0);
for (int i = 0; i < layout.getChildCount(); i++)
{
View v = layout.getChildAt(i);
v.setScaleX(1);
v.setScaleY(1);
v.animate().cancel();
v.animate().translationY(isReversed ? -v.getHeight() :v.getHeight())
.scaleX(0).scaleY(0).setDuration(100)
.setStartDelay(80 * i)
.setInterpolator(null)
.start();
}
// hide view when finish animating
new Handler().postDelayed(new Runnable()
{
@Override
public void run()
{
manager.dismiss();
}
}, 150 * layout.getChildCount());
}
示例14: resetCourseTable
import android.widget.LinearLayout; //导入方法依赖的package包/类
private void resetCourseTable() {
for (int i = 1; i < TABLE_ROW; i++) {
for (int j = 1; j < TABLE_COL; j++) {
LinearLayout tr = (LinearLayout) courseContainer.getChildAt(i);
CourseBlock text = (CourseBlock) tr.getChildAt(j);
text.resetBlock();
}
}
isDisplayABCD = false;
isDisplaySat = false;
isDisplaySun = false;
isDisplayNoTime = false;
requestLayout();
}
示例15: getDesiredHeight
import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
* Calculates desired height for layout
*
* @param layout
* the source layout
* @return the desired layout height
*/
private int getDesiredHeight(LinearLayout layout) {
if (layout != null && layout.getChildAt(0) != null) {
itemHeight = layout.getChildAt(0).getMeasuredHeight();
}
int desired = itemHeight * visibleItems - itemHeight
* ITEM_OFFSET_PERCENT / 50;
return Math.max(desired, getSuggestedMinimumHeight());
}