本文整理汇总了Java中android.widget.LinearLayout.setPadding方法的典型用法代码示例。如果您正苦于以下问题:Java LinearLayout.setPadding方法的具体用法?Java LinearLayout.setPadding怎么用?Java LinearLayout.setPadding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.LinearLayout
的用法示例。
在下文中一共展示了LinearLayout.setPadding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import android.widget.LinearLayout; //导入方法依赖的package包/类
private void init() {
removeAllViews();
View root;
if (mAdjustMode) {
root = LayoutInflater.from(getContext()).inflate(R.layout.pager_navigator_layout_no_scroll, this);
} else {
root = LayoutInflater.from(getContext()).inflate(R.layout.pager_navigator_layout, this);
}
mScrollView = (HorizontalScrollView) root.findViewById(R.id.scroll_view); // mAdjustMode为true时,mScrollView为null
mTitleContainer = (LinearLayout) root.findViewById(R.id.title_container);
mTitleContainer.setPadding(mLeftPadding, 0, mRightPadding, 0);
mIndicatorContainer = (LinearLayout) root.findViewById(R.id.indicator_container);
if (mIndicatorOnTop) {
mIndicatorContainer.getParent().bringChildToFront(mIndicatorContainer);
}
initTitlesAndIndicator();
}
示例2: ColorPickerDialogBuilder
import android.widget.LinearLayout; //导入方法依赖的package包/类
private ColorPickerDialogBuilder(Context context, int theme) {
defaultMargin = getDimensionAsPx(context, R.dimen.default_slider_margin);
final int dialogMarginBetweenTitle = getDimensionAsPx(context, R.dimen.default_slider_margin_btw_title);
builder = new AlertDialog.Builder(context, theme);
pickerContainer = new LinearLayout(context);
pickerContainer.setOrientation(LinearLayout.VERTICAL);
pickerContainer.setGravity(Gravity.CENTER_HORIZONTAL);
pickerContainer.setPadding(defaultMargin, dialogMarginBetweenTitle, defaultMargin, defaultMargin);
LinearLayout.LayoutParams layoutParamsForColorPickerView = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);
layoutParamsForColorPickerView.weight = 1;
colorPickerView = new ColorPickerView(context);
pickerContainer.addView(colorPickerView, layoutParamsForColorPickerView);
builder.setView(pickerContainer);
}
示例3: init
import android.widget.LinearLayout; //导入方法依赖的package包/类
private void init(Context context) {
inflater = LayoutInflater.from(context);
headView = (LinearLayout) inflater.inflate(R.layout.kf5_list_head, null);
arrowImageView = (ImageView) headView.findViewById(R.id.kf5_head_arrowImageView);
arrowImageView.setMinimumWidth(70);
arrowImageView.setMinimumHeight(50);
progressBar = (ProgressBar) headView.findViewById(R.id.kf5_head_progressBar);
tipsTextview = (TextView) headView.findViewById(R.id.kf5_head_tipsTextView);
lastUpdatedTextView = (TextView) headView.findViewById(R.id.kf5_head_lastUpdatedTextView);
measureView(headView);
headContentHeight = headView.getMeasuredHeight();
headContentWidth = headView.getMeasuredWidth();
headView.setPadding(0, -1 * headContentHeight, 0, 0);
headView.invalidate();
addHeaderView(headView);
setOnScrollListener(this);
animation = new RotateAnimation(0, -180,
RotateAnimation.RELATIVE_TO_SELF, 0.5f,
RotateAnimation.RELATIVE_TO_SELF, 0.5f);
animation.setInterpolator(new LinearInterpolator());
animation.setDuration(250);
animation.setFillAfter(true);
reverseAnimation = new RotateAnimation(-180, 0,
RotateAnimation.RELATIVE_TO_SELF, 0.5f,
RotateAnimation.RELATIVE_TO_SELF, 0.5f);
reverseAnimation.setInterpolator(new LinearInterpolator());
reverseAnimation.setDuration(200);
reverseAnimation.setFillAfter(true);
state = DONE;
isRefreshable = false;
}
示例4: setupMainLayout
import android.widget.LinearLayout; //导入方法依赖的package包/类
private void setupMainLayout() {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
setOrientation(VERTICAL);
setLayoutParams(params);
outer_container = new LinearLayout(context);
outer_container.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT, 2f));
outer_container.setOrientation(LinearLayout.HORIZONTAL);
outer_container.setGravity(Gravity.CENTER_HORIZONTAL);
scale = getResources().getDisplayMetrics().density;
dpAsPixels = (int) (13 * scale + 0.5f);
outer_container.setPadding(dpAsPixels, dpAsPixels, dpAsPixels, dpAsPixels);
}
示例5: initBottom
import android.widget.LinearLayout; //导入方法依赖的package包/类
private void initBottom(LinearLayout llBottom, float ratio) {
LinearLayout llAt = new LinearLayout(activity);
llAt.setPadding(0, 0, 0, 5);
llAt.setBackgroundColor(0xffffffff);
int bottomHeight = (int) (DESIGN_BOTTOM_HEIGHT * ratio);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, bottomHeight);
llBottom.addView(llAt, lp);
tvAt = new TextView(activity);
tvAt.setTextColor(0xff3b3b3b);
tvAt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
tvAt.setGravity(Gravity.BOTTOM);
tvAt.setText("@");
int padding = (int) (DESIGN_LEFT_PADDING * ratio);
tvAt.setPadding(padding, 0, padding, 0);
lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
llAt.addView(tvAt, lp);
tvAt.setOnClickListener(this);
if (isShowAtUserLayout(platform.getName())) {
tvAt.setVisibility(View.VISIBLE);
} else {
tvAt.setVisibility(View.INVISIBLE);
}
tvTextCouter = new TextView(activity);
tvTextCouter.setTextColor(0xff3b3b3b);
tvTextCouter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
tvTextCouter.setGravity(Gravity.BOTTOM | Gravity.RIGHT);
onTextChanged(etContent.getText(), 0, 0, 0);
tvTextCouter.setPadding(padding, 0, padding, 0);
lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
lp.weight = 1;
llAt.addView(tvTextCouter, lp);
View v = new View(activity);
v.setBackgroundColor(0xffcccccc);
int px_1 = ratio > 1 ? ((int) ratio) : 1;
lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, px_1);
llBottom.addView(v, lp);
}
示例6: makeContentView
import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
* @see #makeHeaderView()
* @see #makeCenterView()
* @see #makeFooterView()
*/
@Override
protected final View makeContentView() {
LinearLayout rootLayout = new LinearLayout(activity);
rootLayout.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
rootLayout.setBackgroundColor(backgroundColor);
rootLayout.setOrientation(LinearLayout.VERTICAL);
rootLayout.setGravity(Gravity.CENTER);
int padding = ConvertUtils.toPx(activity, contentPaddingLefAndRight);
rootLayout.setPadding(padding, 0, padding, 0);
rootLayout.setClipToPadding(false);
View headerView = makeHeaderView();
//2017-8-10 lyy 调整头部按钮的显示位置到底部
// if (headerView != null) {
// rootLayout.addView(headerView);
// }
// if (topLineVisible) {
// View lineView = new View(activity);
// lineView.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, topLineHeightPixels));
// lineView.setBackgroundColor(topLineColor);
// rootLayout.addView(lineView);
// }
rootLayout.addView(makeCenterView(), new LinearLayout.LayoutParams(MATCH_PARENT, 0, 1.0f));
View footerView = makeFooterView();
if (footerView != null) {
footerView.setPadding(padding, 0, padding, 0);
rootLayout.addView(footerView);
}
if (topLineVisible) {
View lineView = new View(activity);
lineView.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, topLineHeightPixels));
lineView.setBackgroundColor(topLineColor);
rootLayout.addView(lineView);
}
if (headerView != null) {
rootLayout.addView(headerView);
}
return rootLayout;
}
示例7: initBottom
import android.widget.LinearLayout; //导入方法依赖的package包/类
private void initBottom(LinearLayout llBottom, float ratio) {
LinearLayout llAt = new LinearLayout(activity);
llAt.setPadding(0, 0, 0, 5);
llAt.setBackgroundColor(0xffffffff);
int bottomHeight = (int) (DESIGN_BOTTOM_HEIGHT * ratio);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, bottomHeight);
llBottom.addView(llAt, lp);
tvAt = new TextView(activity);
tvAt.setTextColor(0xff3b3b3b);
tvAt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
tvAt.setGravity(Gravity.BOTTOM);
tvAt.setText("@");
int padding = (int) (DESIGN_LEFT_PADDING * ratio);
tvAt.setPadding(padding, 0, padding, 0);
lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
llAt.addView(tvAt, lp);
tvAt.setOnClickListener(this);
if (isShowAtUserLayout(platform.getName())) {
tvAt.setVisibility(View.VISIBLE);
} else {
tvAt.setVisibility(View.INVISIBLE);
}
tvTextCouter = new TextView(activity);
tvTextCouter.setTextColor(0xff3b3b3b);
tvTextCouter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
tvTextCouter.setGravity(Gravity.BOTTOM | Gravity.RIGHT);
onTextChanged(etContent.getText(), 0, 0, 0);
tvTextCouter.setPadding(padding, 0, padding, 0);
lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
lp.weight = 1;
llAt.addView(tvTextCouter, lp);
View v = new View(activity);
v.setBackgroundColor(0xffcccccc);
int px1 = ratio > 1 ? ((int) ratio) : 1;
lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, px1);
llBottom.addView(v, lp);
}
示例8: initBottom
import android.widget.LinearLayout; //导入方法依赖的package包/类
private void initBottom(LinearLayout llBottom, float ratio) {
LinearLayout llAt = new LinearLayout(activity);
llAt.setPadding(0, 0, 0, 5);
llAt.setBackgroundColor(0xffffffff);
int bottomHeight = (int) (DESIGN_BOTTOM_HEIGHT * ratio);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, bottomHeight);
llBottom.addView(llAt, lp);
tvAt = new TextView(activity);
tvAt.setTextColor(0xff3b3b3b);
tvAt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
tvAt.setGravity(Gravity.BOTTOM);
tvAt.setText("@");
int padding = (int) (DESIGN_LEFT_PADDING * ratio);
tvAt.setPadding(padding, 0, padding, 0);
lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
llAt.addView(tvAt, lp);
tvAt.setOnClickListener(this);
if (isShowAtUserLayout(platform.getName())) {
tvAt.setVisibility(View.VISIBLE);
} else {
tvAt.setVisibility(View.INVISIBLE);
}
tvTextCouter = new TextView(activity);
tvTextCouter.setTextColor(0xff3b3b3b);
tvTextCouter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
tvTextCouter.setGravity(Gravity.BOTTOM | Gravity.RIGHT);
onTextChanged(etContent.getText(), 0, 0, 0);
tvTextCouter.setPadding(padding, 0, padding, 0);
lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
lp.weight = 1;
llAt.addView(tvTextCouter, lp);
View v = new View(activity);
v.setBackgroundColor(0xffcccccc);
int px1 = ratio > 1 ? ((int) ratio) : 1;
lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, px1);
llBottom.addView(v, lp);
}
示例9: initBottom
import android.widget.LinearLayout; //导入方法依赖的package包/类
private void initBottom(LinearLayout llBottom, float ratio) {
LinearLayout llAt = new LinearLayout(activity);
llAt.setPadding(0, 0, 0, 5);
llAt.setBackgroundColor(0xffffffff);
int bottomHeight = (int) (DESIGN_BOTTOM_HEIGHT * ratio);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, bottomHeight);
llBottom.addView(llAt, lp);
tvAt = new TextView(activity);
tvAt.setTextColor(0xff3b3b3b);
tvAt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
tvAt.setGravity(Gravity.BOTTOM);
tvAt.setText("@");
int padding = (int) (DESIGN_LEFT_PADDING * ratio);
tvAt.setPadding(padding, 0, padding, 0);
lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
llAt.addView(tvAt, lp);
tvAt.setOnClickListener(this);
if (isShowAtUserLayout(platform.getName())) {
tvAt.setVisibility(View.VISIBLE);
} else {
tvAt.setVisibility(View.INVISIBLE);
}
tvTextCouter = new TextView(activity);
tvTextCouter.setTextColor(0xff3b3b3b);
tvTextCouter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
tvTextCouter.setGravity(Gravity.BOTTOM | Gravity.RIGHT);
onTextChanged(etContent.getText(), 0, 0, 0);
tvTextCouter.setPadding(padding, 0, padding, 0);
lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
lp.weight = 1;
llAt.addView(tvTextCouter, lp);
View v = new View(activity);
v.setBackgroundColor(0xffcccccc);
int px_1 = ratio > 1 ? ((int) ratio) : 1;
lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, px_1);
llBottom.addView(v, lp);
}
示例10: getView
import android.widget.LinearLayout; //导入方法依赖的package包/类
public View getView(int position, View convertView, ViewGroup parent) {
FollowListItem item;
boolean simpleMode = "FacebookMessenger".equals(this.platform.getName());
if (convertView == null) {
View llItem = new LinearLayout(parent.getContext());
item = new FollowListItem();
llItem.setTag(item);
convertView = llItem;
int dp_52 = R.dipToPx(getContext(), 52);
int dp_10 = R.dipToPx(parent.getContext(), 10);
int dp_5 = R.dipToPx(parent.getContext(), 5);
if (!simpleMode) {
item.aivIcon = new AsyncImageView(getContext());
LayoutParams lpIcon = new LayoutParams(dp_52, dp_52);
lpIcon.gravity = 16;
lpIcon.setMargins(dp_10, dp_5, dp_10, dp_5);
item.aivIcon.setLayoutParams(lpIcon);
llItem.addView(item.aivIcon);
}
LinearLayout llText = new LinearLayout(parent.getContext());
llText.setPadding(0, dp_10, dp_10, dp_10);
llText.setOrientation(1);
LayoutParams lpText = new LayoutParams(-2, -2);
lpText.gravity = 16;
lpText.weight = 1.0f;
llText.setLayoutParams(lpText);
llItem.addView(llText);
item.tvName = new TextView(parent.getContext());
item.tvName.setTextColor(-16777216);
item.tvName.setTextSize(1, 18.0f);
item.tvName.setSingleLine();
if (simpleMode) {
item.tvName.setPadding(dp_10, 0, 0, 0);
}
llText.addView(item.tvName);
if (!simpleMode) {
item.tvSign = new TextView(parent.getContext());
item.tvSign.setTextColor(2130706432);
item.tvSign.setTextSize(1, 14.0f);
item.tvSign.setSingleLine();
llText.addView(item.tvSign);
}
item.ivCheck = new ImageView(parent.getContext());
item.ivCheck.setPadding(0, 0, dp_10, 0);
LayoutParams lpCheck = new LayoutParams(-2, -2);
lpCheck.gravity = 16;
item.ivCheck.setLayoutParams(lpCheck);
llItem.addView(item.ivCheck);
} else {
item = (FollowListItem) convertView.getTag();
}
Following following = getItem(position);
item.tvName.setText(following.screenName);
if (!simpleMode) {
item.tvSign.setText(following.description);
}
item.ivCheck.setImageBitmap(following.checked ? this.bmChd : this.bmUnch);
if (!simpleMode) {
if (isFling()) {
Bitmap bm = BitmapProcessor.getBitmapFromCache(following.icon);
if (bm == null || bm.isRecycled()) {
item.aivIcon.execute(null, 0);
} else {
item.aivIcon.setImageBitmap(bm);
}
} else {
item.aivIcon.execute(following.icon, 0);
}
}
if (position == getCount() - 1) {
next();
}
return convertView;
}
示例11: init
import android.widget.LinearLayout; //导入方法依赖的package包/类
private void init(Context context) {
setCacheColorHint(context.getResources().getColor(ResourceUtils.getIdByName(getContext(), "color",
"sobot_transparent")));
inflater = LayoutInflater.from(context);
fl = (FrameLayout)inflater.inflate(ResourceUtils.getIdByName(getContext(), "layout",
"sobot_dropdown_lv_head"), null);
headView = (LinearLayout) fl.findViewById(ResourceUtils.getIdByName(getContext(), "id",
"drop_down_head"));
progressBar = (ProgressBar) fl.findViewById(ResourceUtils.getIdByName(getContext(), "id",
"sobot_loading"));
measureView(headView);
headContentHeight = headView.getMeasuredHeight();
headContentWidth = headView.getMeasuredWidth();
headView.setPadding(0, -1 * headContentHeight, 0, 0);
headView.invalidate();
Log.v("size", "width:" + headContentWidth + " height:"
+ headContentHeight);
addHeaderView(fl, null, false);
// addHeaderView(headView, null, false);
setOnScrollListener(this);
state = DONE;
isRefreshableHeader = false;
}
示例12: onCreate
import android.widget.LinearLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mRed = 0xFF;
mGreen = 0x40;
mBlue = 0x81;
setContentView(R.layout.activity_full);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mToolbar.setBackgroundColor(Color.TRANSPARENT);
mImgHeader = (ImageView) findViewById(R.id.img_header);
int navigationBarColor;
ImmerseConfiguration.Builder builder = new ImmerseConfiguration.Builder();
Bundle bundle = getIntent().getExtras();
String paras = bundle.getString("Mode");
if ("NSB_NNB".equals(paras)) {
builder.setStatusBarModeInKK(ImmerseConfiguration.NORMAL).setNavigationBarModeInKK(ImmerseConfiguration.NORMAL)
.setFullScreenInKK(false);
builder.setStatusBarModeInL(ImmerseConfiguration.NORMAL).setNavigationBarModeInL(ImmerseConfiguration.NORMAL)
.setFullScreenInL(false);
navigationBarColor = ContextCompat.getColor(this, R.color.colorAccent);
} else if ("TLSB_NNB_FC".equals(paras)) {
builder.setStatusBarModeInKK(ImmerseConfiguration.TRANSLUCENT).setNavigationBarModeInKK(ImmerseConfiguration.NORMAL)
.setFullScreenInKK(true);
builder.setStatusBarModeInL(ImmerseConfiguration.TRANSLUCENT).setNavigationBarModeInL(ImmerseConfiguration.NORMAL)
.setFullScreenInL(true);
navigationBarColor = ContextCompat.getColor(this, R.color.colorAccent);
} else if ("TLSB_TLNB_FC".equals(paras)) {
builder.setStatusBarModeInKK(ImmerseConfiguration.TRANSLUCENT).setNavigationBarModeInKK(ImmerseConfiguration.TRANSLUCENT)
.setFullScreenInKK(true);
builder.setStatusBarModeInL(ImmerseConfiguration.TRANSLUCENT).setNavigationBarModeInL(ImmerseConfiguration.TRANSLUCENT)
.setFullScreenInL(true);
navigationBarColor = Color.TRANSPARENT;
} else if ("TPSB_NNB_FC".equals(paras)) {
// Kitkat不支持全透状态栏+普通导航栏,故而降级到半透状态栏+普通导航栏
builder.setStatusBarModeInKK(ImmerseConfiguration.TRANSLUCENT).setNavigationBarModeInKK(ImmerseConfiguration.NORMAL)
.setFullScreenInKK(true);
builder.setStatusBarModeInL(ImmerseConfiguration.TRANSPARENT).setNavigationBarModeInL(ImmerseConfiguration.NORMAL)
.setFullScreenInL(true);
navigationBarColor = ContextCompat.getColor(this, R.color.colorAccent);
} else if ("TPSB_TLNB_FC".equals(paras)) {
// Kitkat不支持全透状态栏+半透导航栏,故而降级到半透状态栏+半透导航栏
builder.setStatusBarModeInKK(ImmerseConfiguration.TRANSLUCENT).setNavigationBarModeInKK(ImmerseConfiguration.TRANSLUCENT)
.setFullScreenInKK(true);
builder.setStatusBarModeInL(ImmerseConfiguration.TRANSPARENT).setNavigationBarModeInL(ImmerseConfiguration.TRANSLUCENT)
.setFullScreenInL(true);
navigationBarColor = Color.TRANSPARENT;
} else {
// 补偿逻辑
builder.setStatusBarModeInKK(ImmerseConfiguration.NORMAL).setNavigationBarModeInKK(ImmerseConfiguration.NORMAL)
.setFullScreenInKK(false);
builder.setStatusBarModeInL(ImmerseConfiguration.NORMAL).setNavigationBarModeInL(ImmerseConfiguration.NORMAL)
.setFullScreenInL(false);
navigationBarColor = ContextCompat.getColor(this, R.color.colorAccent);
}
mImmerseHelper = new ImmerseHelper(this, builder.build());
mImmerseHelper.setStatusColor(Color.TRANSPARENT);
mImmerseHelper.setNavigationColor(navigationBarColor);
ExScrollView scrollView = (ExScrollView) findViewById(R.id.scroll_view);
scrollView.setOnScrollChangeListener(mCommonListener);
LinearLayout contentLayout = (LinearLayout) findViewById(R.id.activity_full_content);
Rect insetsRest = mImmerseHelper.getInsetsPadding();
contentLayout.setPadding(0, 0, insetsRest.right, insetsRest.bottom);
}
示例13: onBindViewHolder
import android.widget.LinearLayout; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
Message current = messagesArray[position];
final View v = holder.itemView;
final TextView datum = v.findViewById(R.id.textViewDate);
final TextView nachricht = v.findViewById(R.id.nachricht);
final TextView absender = v.findViewById(R.id.absender);
final TextView uhrzeit = v.findViewById(R.id.datum);
final LinearLayout layout = v.findViewById(R.id.chatbubblewrapper);
final View chatbubble = v.findViewById(R.id.chatbubble);
final View progressbar = v.findViewById(R.id.progressBar);
nachricht.setText(current.mtext);
absender.setText(current.uname);
uhrzeit.setText(current.getTime());
datum.setText(current.getDate());
final boolean mine = current.uid == Utils.getUserID();
if (mine) {
layout.setGravity(Gravity.END);
absender.setVisibility(View.GONE);
nachricht.setTextColor(ContextCompat.getColor(context, android.R.color.background_light));
uhrzeit.setTextColor(ContextCompat.getColor(context, android.R.color.background_light));
} else {
layout.setGravity(Gravity.START);
nachricht.setTextColor(ContextCompat.getColor(context, android.R.color.background_dark));
uhrzeit.setTextColor(ContextCompat.getColor(context, android.R.color.background_dark));
if (ctype == Chat.ChatType.PRIVATE) {
absender.setVisibility(View.GONE);
} else {
absender.setVisibility(View.VISIBLE);
}
}
chatbubble.setEnabled(mine);
final boolean send = uhrzeit.getText().toString().equals("");
if (send) {
uhrzeit.setVisibility(View.GONE);
progressbar.setVisibility(View.VISIBLE);
} else {
uhrzeit.setVisibility(View.VISIBLE);
progressbar.setVisibility(View.GONE);
}
final boolean first = position == 0 || !gleicherTag(current.mdate, messagesArray[position - 1].mdate);
if (first) {
datum.setVisibility(View.VISIBLE);
layout.setPadding((int) GraphicUtils.dpToPx(6), (int) GraphicUtils.dpToPx(3), (int) GraphicUtils.dpToPx(6), (int) GraphicUtils.dpToPx(3));
} else {
datum.setVisibility(View.GONE);
if (current.uid == messagesArray[position - 1].uid) {
absender.setVisibility(View.GONE);
layout.setPadding((int) GraphicUtils.dpToPx(6), (int) GraphicUtils.dpToPx(0), (int) GraphicUtils.dpToPx(6), (int) GraphicUtils.dpToPx(3));
} else {
layout.setPadding((int) GraphicUtils.dpToPx(6), (int) GraphicUtils.dpToPx(3), (int) GraphicUtils.dpToPx(6), (int) GraphicUtils.dpToPx(3));
}
}
if (selected[position]) {
v.findViewById(R.id.chatbubblewrapper).setBackgroundColor(ContextCompat.getColor(context, R.color.colorAccentTransparent));
} else {
v.findViewById(R.id.chatbubblewrapper).setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent));
}
// if (current.mread && (position == 0 || !messagesArray[position - 1].mread)) {
// v.findViewById(R.id.linearLayout1).setVisibility(View.VISIBLE);
// } else {
// v.findViewById(R.id.linearLayout1).setVisibility(View.GONE);
// }
}
示例14: initFooterView
import android.widget.LinearLayout; //导入方法依赖的package包/类
private View initFooterView() {
footerView = new LinearLayout(aty);
footerView.setPadding(20, 0, 20, 20);
footerView.setOrientation(LinearLayout.VERTICAL);
return footerView;
}
示例15: initView
import android.widget.LinearLayout; //导入方法依赖的package包/类
private void initView() {
this.setOrientation(VERTICAL);
this.removeAllViews();
if(MAX_WIDTH == 0){
//为了触发onMeasure()来测量MultiImageView的最大宽度,MultiImageView的宽设置为match_parent
addView(new View(getContext()));
return;
}
if (imagesList == null || imagesList.size() == 0) {
return;
}
if (imagesList.size() == 1) {
addView(createImageView(0, false));
} else {
int allCount = imagesList.size();
if(allCount == 4){
MAX_PER_ROW_COUNT = 2;
}else{
MAX_PER_ROW_COUNT = 3;
}
int rowCount = allCount / MAX_PER_ROW_COUNT
+ (allCount % MAX_PER_ROW_COUNT > 0 ? 1 : 0);// 行数
for (int rowCursor = 0; rowCursor < rowCount; rowCursor++) {
LinearLayout rowLayout = new LinearLayout(getContext());
rowLayout.setOrientation(LinearLayout.HORIZONTAL);
rowLayout.setLayoutParams(rowPara);
if (rowCursor != 0) {
rowLayout.setPadding(0, pxImagePadding, 0, 0);
}
int columnCount = allCount % MAX_PER_ROW_COUNT == 0 ? MAX_PER_ROW_COUNT
: allCount % MAX_PER_ROW_COUNT;//每行的列数
if (rowCursor != rowCount - 1) {
columnCount = MAX_PER_ROW_COUNT;
}
addView(rowLayout);
int rowOffset = rowCursor * MAX_PER_ROW_COUNT;// 行偏移
for (int columnCursor = 0; columnCursor < columnCount; columnCursor++) {
int position = columnCursor + rowOffset;
rowLayout.addView(createImageView(position, true));
}
}
}
}