Java Code Examples for android.widget.LinearLayout.getContext()

The following are Jave code examples for showing how to use getContext() of the android.widget.LinearLayout class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: bikedeboa-android   File: BindingAdapters.java   View Source Code Vote up 7 votes
@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);
	}
}
 
Example 2
Project: navigation-widgets   File: NavigationLayoutFactory.java   View Source Code Vote up 7 votes
@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;
}
 
Example 3
Project: Vidsta   File: ListenerHelper.java   View Source Code Vote up 6 votes
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);
        }
    });
}
 
Example 4
Project: chromium-for-android-56-debug-video   File: PaymentRequestSection.java   View Source Code Vote up 6 votes
@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);
}
 
Example 5
Project: XposedNavigationBar   File: NavBarHook.java   View Source Code Vote up 6 votes
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);
        }
    });
}
 
Example 6
Project: XposedNavigationBar   File: BtnFuncFactory.java   View Source Code Vote up 6 votes
/**
 * 创建按钮并且设置对应功能
 *
 * @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);
}
 
Example 7
Project: chromium-for-android-56-debug-video   File: PaymentRequestSection.java   View Source Code Vote up 5 votes
@Override
protected void createMainSectionContent(LinearLayout mainSectionLayout) {
    Context context = mainSectionLayout.getContext();

    mExtraTextViews = new TextView[3];
    for (int i = 0; i < mExtraTextViews.length; i++) {
        mExtraTextViews[i] = new TextView(context);
        ApiCompatibilityUtils.setTextAppearance(
                mExtraTextViews[i], R.style.PaymentsUiSectionDefaultText);
        mainSectionLayout.addView(
                mExtraTextViews[i], new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                                            LayoutParams.WRAP_CONTENT));
    }
}
 
Example 8
Project: chromium-for-android-56-debug-video   File: PaymentRequestSection.java   View Source Code Vote up 5 votes
@Override
protected void createMainSectionContent(LinearLayout mainSectionLayout) {
    Context context = mainSectionLayout.getContext();
    mCheckingProgress = createLoadingSpinner();

    mOptionLayout = new GridLayout(context);
    mOptionLayout.setColumnCount(4);
    mainSectionLayout.addView(mOptionLayout, new LinearLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
}
 
Example 9
Project: boohee_v5.6   File: MonthView.java   View Source Code Vote up 5 votes
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;
}
 
Example 10
Project: android_nextgis_mobile   File: LocalResourceListAdapter.java   View Source Code Vote up 4 votes
public PathAdapter(LinearLayout linearLayout)
{
    mLinearLayout = linearLayout;
    mContext = linearLayout.getContext();
}
 
Example 11
Project: XposedNavigationBar   File: NavBarHook.java   View Source Code Vote up 4 votes
private static void initMusicPanel(LinearLayout musicPanel) {
    Context context = musicPanel.getContext();
    musicControllerPanel = new MusicControllerPanel(context);
    musicControllerPanel.initPanel();
}