本文整理汇总了Java中android.widget.LinearLayout.getContext方法的典型用法代码示例。如果您正苦于以下问题:Java LinearLayout.getContext方法的具体用法?Java LinearLayout.getContext怎么用?Java LinearLayout.getContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.LinearLayout
的用法示例。
在下文中一共展示了LinearLayout.getContext方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: produceLayout
import android.widget.LinearLayout; //导入方法依赖的package包/类
@Override
public View produceLayout(LayoutInflater inflater, @Nullable ViewGroup container) {
LinearLayout parent = new LinearLayout(inflater.getContext());
parent.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
parent.setOrientation(VERTICAL);
View child = origin.produceLayout(inflater, parent);
LinearLayout.LayoutParams childParams = new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);
if (includeBottomBar) {
childParams.weight = 1;
}
if (includeToolbar) {
inflater.inflate(R.layout.toolbar, parent);
}
parent.addView(child, childParams);
if (includeBottomBar) {
AHBottomNavigation bottomNavigation = new AHBottomNavigation(parent.getContext());
bottomNavigation.setId(R.id.bottomNavigation);
parent.addView(
bottomNavigation,
new LinearLayout.LayoutParams(MATCH_PARENT, (int) dp(parent.getContext(), 56)));
}
return parent;
}
示例3: createListenerLog
import android.widget.LinearLayout; //导入方法依赖的package包/类
static void createListenerLog(LinearLayout messagesContainer, String text) {
String currentDateTime = new SimpleDateFormat("HH:mm:ss.SSS", Locale.getDefault()).format(new Date());
TextView textView = new TextView(messagesContainer.getContext());
textView.setTextColor(Color.WHITE);
textView.setTextSize(14);
textView.setText(currentDateTime + ": " + text);
messagesContainer.addView(textView);
final ScrollView scrollView = (ScrollView)messagesContainer.getParent();
scrollView.post(new Runnable() {
public void run() {
scrollView.fullScroll(ScrollView.FOCUS_DOWN);
}
});
}
示例4: createMainSectionContent
import android.widget.LinearLayout; //导入方法依赖的package包/类
@Override
protected void createMainSectionContent(LinearLayout mainSectionLayout) {
Context context = mainSectionLayout.getContext();
// Add a label that will be used to indicate that the total cart price has been updated.
addUpdateText(mainSectionLayout);
// The breakdown is represented by an end-aligned GridLayout that takes up only as much
// space as it needs. The GridLayout ensures a consistent margin between the columns.
mBreakdownLayout = new GridLayout(context);
mBreakdownLayout.setColumnCount(2);
LayoutParams breakdownParams =
new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
breakdownParams.gravity = Gravity.END;
mainSectionLayout.addView(mBreakdownLayout, breakdownParams);
}
示例5: initHomeNavbar
import android.widget.LinearLayout; //导入方法依赖的package包/类
private static void initHomeNavbar(LinearLayout homeNavbar, final ViewPager vp) {
XpLog.i("initHomeNavbar");
Context context = homeNavbar.getContext();
ImageButton btnCall = new ImageButton(context);
btnCall.setImageBitmap(ImageUtil.byte2Bitmap(DataHook.mapImgRes.get(ConstantStr.FUNC_SMALL_POINT_CODE)));
btnCall.setScaleType(ImageView.ScaleType.FIT_CENTER);
btnCall.setBackgroundColor(Color.alpha(255));
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
homeNavbar.addView(btnCall, params);
setHomePointPosition(homeNavbar);
btnCall.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
vp.setCurrentItem(2);
}
});
}
示例6: createBtnAndSetFunc
import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
* 创建按钮并且设置对应功能
*
* @param line
* @param sc
*/
public void createBtnAndSetFunc(LinearLayout line, ShortCut sc) {
int iconScale = DataHook.iconScale;
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
p.weight = 1;
p.gravity = Gravity.CENTER;
Context context = line.getContext();
ImageView btn = new ImageView(context);
String iconPath = sc.getIconPath();
Bitmap iconBitmap = null;
if (iconPath != null) {
iconBitmap = ImageUtil.zoomBitmap(iconPath, iconScale);
}
if (iconBitmap == null) {
iconBitmap = ImageUtil.byte2Bitmap(mMapImgRes.get(sc.getCode()));
iconBitmap = ImageUtil.zommBitmap(iconBitmap, iconScale);
}
btn.setImageBitmap(iconBitmap);
ColorStateList colorStateList = createColorStateList(0xffffffff, 0xffffff00, 0xff0000ff, 0xffff0000);
RippleDrawable ripple = new RippleDrawable(colorStateList, null, null);
btn.setBackground(ripple);
btn.setScaleType(ImageView.ScaleType.CENTER);
btn.setOnClickListener(getBtnFuncOfName(sc));
btn.setOnLongClickListener(getBtnLongFuncOfName(sc.getCode()));
line.addView(btn, p);
}
示例7: makeRow
import android.widget.LinearLayout; //导入方法依赖的package包/类
private static LinearLayout makeRow(LinearLayout parent) {
LinearLayout row = new LinearLayout(parent.getContext());
row.setOrientation(0);
parent.addView(row, new LayoutParams(-1, 0, 1.0f));
View v = new View(parent.getContext());
v.setBackgroundColor(Color.parseColor("#60000000"));
parent.addView(v, new LayoutParams(-1, 1));
return row;
}
示例8: PathAdapter
import android.widget.LinearLayout; //导入方法依赖的package包/类
public PathAdapter(LinearLayout linearLayout)
{
mLinearLayout = linearLayout;
mContext = linearLayout.getContext();
}
示例9: initMusicPanel
import android.widget.LinearLayout; //导入方法依赖的package包/类
private static void initMusicPanel(LinearLayout musicPanel) {
Context context = musicPanel.getContext();
musicControllerPanel = new MusicControllerPanel(context);
musicControllerPanel.initPanel();
}