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

The following are Jave code examples for showing how to use setLayoutTransition() 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: BarChart   File: BarChart.java   View Source Code Vote up 5 votes
private void initHorizontalChart() {
    horizontalLinearParent = new LinearLayout(context);
    horizontalLinearParent.setOrientation(LinearLayout.VERTICAL);
    horizontalLinearParent.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    horizontalLinearParent.setGravity(Gravity.LEFT | Gravity.START);
    if (isShowAnimation) {
        horizontalLinearParent.setLayoutTransition(new LayoutTransition());
    }
    this.addView(horizontalLinearParent);
}
 
Example 2
Project: BarChart   File: BarChart.java   View Source Code Vote up 5 votes
private void initVerticalChart() {
    verticalLinearParent = new LinearLayout(context);
    verticalLinearParent.setOrientation(LinearLayout.HORIZONTAL);
    verticalLinearParent.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    verticalLinearParent.setGravity(Gravity.BOTTOM);
    if (isShowAnimation) {
        verticalLinearParent.setLayoutTransition(new LayoutTransition());
    }
    this.addView(verticalLinearParent);
}
 
Example 3
Project: FakeWeather   File: WeatherChartView.java   View Source Code Vote up 4 votes
private void letItGo() {
    removeAllViews();
    final LinearLayout dateTitleView = new LinearLayout(getContext());
    dateTitleView.setLayoutParams(rowParams);
    dateTitleView.setOrientation(HORIZONTAL);
    dateTitleView.setLayoutTransition(transition);
    dateTitleView.removeAllViews();

    final LinearLayout iconView = new LinearLayout(getContext());
    iconView.setLayoutParams(rowParams);
    iconView.setOrientation(HORIZONTAL);
    iconView.setLayoutTransition(transition);
    iconView.removeAllViews();

    final LinearLayout weatherStrView = new LinearLayout(getContext());
    weatherStrView.setLayoutParams(rowParams);
    weatherStrView.setOrientation(HORIZONTAL);
    weatherStrView.setLayoutTransition(transition);
    weatherStrView.removeAllViews();

    List<Integer> minTemp = new ArrayList<>();
    List<Integer> maxTemp = new ArrayList<>();
    for (int i = 0; i < dailyForecastList.size(); i++) {
        final TextView tvDate = new TextView(getContext());
        tvDate.setGravity(Gravity.CENTER);
        tvDate.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10);
        tvDate.setTextColor(getResources().getColor(R.color.colorTextDark));
        tvDate.setVisibility(INVISIBLE);
        final TextView tvWeather = new TextView((getContext()));
        tvWeather.setGravity(Gravity.CENTER);
        tvWeather.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10);
        tvWeather.setTextColor(getResources().getColor(R.color.colorTextDark));
        tvWeather.setVisibility(INVISIBLE);
        final ImageView ivIcon = new ImageView(getContext());
        ivIcon.setAdjustViewBounds(true);
        ivIcon.setScaleType(ImageView.ScaleType.FIT_CENTER);
        int padding = SizeUtils.dp2px(getContext(), 10);
        int width = SizeUtils.getScreenWidth(getContext()) / dailyForecastList.size();
        LayoutParams ivParam = new LayoutParams(width, width);
        ivParam.weight = 1;
        ivIcon.setLayoutParams(ivParam);
        ivIcon.setPadding(padding, padding, padding, padding);
        ivIcon.setVisibility(INVISIBLE);
        tvDate.setText(dailyForecastList.get(i).getDate());
        tvWeather.setText(dailyForecastList.get(i).getTxt());
        WeatherUtil.getInstance().getWeatherDict(dailyForecastList.get(i).getCode()).observeOn(AndroidSchedulers.mainThread()).subscribe(new SimpleSubscriber<WeatherBean>() {
            @Override
            public void onNext(WeatherBean weatherBean) {
                Glide.with(getContext()).load(weatherBean.getIcon()).diskCacheStrategy(DiskCacheStrategy.ALL).into(ivIcon);
            }
        });
        minTemp.add(Integer.valueOf(dailyForecastList.get(i).getMinTemp()));
        maxTemp.add(Integer.valueOf(dailyForecastList.get(i).getMaxTemp()));
        weatherStrView.addView(tvWeather, cellParams);
        dateTitleView.addView(tvDate, cellParams);
        iconView.addView(ivIcon);
        this.postDelayed(new Runnable() {
            @Override
            public void run() {
                tvDate.setVisibility(VISIBLE);
                tvWeather.setVisibility(VISIBLE);
                ivIcon.setVisibility(VISIBLE);
            }
        }, 200 * i);
    }
    addView(dateTitleView);
    addView(iconView);
    addView(weatherStrView);
    final ChartView chartView = new ChartView(getContext());
    chartView.setData(minTemp, maxTemp);
    chartView.setPadding(0, SizeUtils.dp2px(getContext(), 16), 0, SizeUtils.dp2px(getContext(), 16));
    addView(chartView, chartParams);
}